All pastes #106766 Raw Edit

apachelogger

public text v1 · immutable
#106766 ·published 2006-07-30 15:42 UTC
rendered paste body
Stock = Struct.new( "Stock", :amount, :max, :beats, :deliverybeat, :version )

class BAREXTPlugin < Plugin

  def initialize()
    super
    if @registry.has_key?(:stock)
      @stock = @registry[:stock]
    else
      @stock = Hash.new
    end
  end

  def handle_add( m, params )
    name         = params[:name].downcase
    amount       = params[:amount]
    beats        = params[:beats]
    version      = "1"

    beats = beats.to_f / amount.to_f
    beats *= 100

    stock = Stock.new( amount, amount, beats, nil, version )
    @stock[name] = stock

    m.reply( "done" )
  end

end