class Ubea::Offer
Attributes
price[R]
volume[R]
weighted_price[R]
Public Class Methods
new(hash)
click to toggle source
# File lib/ubea/offer.rb, line 7 def initialize(hash) self.price = hash.delete(:price) self.weighted_price = hash.delete(:weighted_price) self.volume = Money.new(hash.delete(:volume), "BTC") raise ArgumentError unless hash.empty? raise ArgumentError, "#{price.class} is not Money" unless price.is_a? Money end
Public Instance Methods
inspect()
click to toggle source
# File lib/ubea/offer.rb, line 24 def inspect "#<Ubea::Offer price=#{price} volume=#{volume}>" end
Also aliased as: to_s
price=(price)
click to toggle source
# File lib/ubea/offer.rb, line 30 def price=(price) raise ArgumentError if price < 0 @price = price end
to_h()
click to toggle source
# File lib/ubea/offer.rb, line 16 def to_h { weighted_price: weighted_price.to_f.to_s, limit_price: price.to_f.to_s, volume: volume.to_f.to_s, } end
volume=(volume)
click to toggle source
# File lib/ubea/offer.rb, line 40 def volume=(volume) raise ArgumentError if volume < 0 @volume = volume end
weighted_price=(weighted_price)
click to toggle source
# File lib/ubea/offer.rb, line 35 def weighted_price=(weighted_price) raise ArgumentError if weighted_price && weighted_price < 0 @weighted_price = weighted_price end