Class: Bitstamper::Models::Ticker
- Defined in:
- lib/bitstamper/models/ticker.rb
Constant Summary collapse
- MAPPING =
{ "high" => :float, "last" => :float, "timestamp" => :time, "bid" => :float, "vwap" => :float, "volume" => :float, "low" => :float, "ask" => :float, "open" => :float, "currency_pair" => :string, }
Instance Attribute Summary collapse
-
#ask ⇒ Object
Returns the value of attribute ask.
-
#bid ⇒ Object
Returns the value of attribute bid.
-
#currency_pair ⇒ Object
Returns the value of attribute currency_pair.
-
#high ⇒ Object
Returns the value of attribute high.
-
#last ⇒ Object
Returns the value of attribute last.
-
#low ⇒ Object
Returns the value of attribute low.
-
#open ⇒ Object
Returns the value of attribute open.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#volume ⇒ Object
Returns the value of attribute volume.
-
#vwap ⇒ Object
Returns the value of attribute vwap.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ Ticker
constructor
A new instance of Ticker.
Methods inherited from Base
Constructor Details
#initialize(hash) ⇒ Ticker
Returns a new instance of Ticker.
19 20 21 22 23 24 25 |
# File 'lib/bitstamper/models/ticker.rb', line 19 def initialize(hash) hash.each do |key, value| type = ::Bitstamper::Models::Ticker::MAPPING.fetch(key, nil) value = value && type ? ::Bitstamper::Utilities::convert_value(value, type) : value self.send("#{key}=", value) if self.respond_to?(key) end end |
Instance Attribute Details
#ask ⇒ Object
Returns the value of attribute ask.
4 5 6 |
# File 'lib/bitstamper/models/ticker.rb', line 4 def ask @ask end |
#bid ⇒ Object
Returns the value of attribute bid.
4 5 6 |
# File 'lib/bitstamper/models/ticker.rb', line 4 def bid @bid end |
#currency_pair ⇒ Object
Returns the value of attribute currency_pair.
4 5 6 |
# File 'lib/bitstamper/models/ticker.rb', line 4 def currency_pair @currency_pair end |
#high ⇒ Object
Returns the value of attribute high.
4 5 6 |
# File 'lib/bitstamper/models/ticker.rb', line 4 def high @high end |
#last ⇒ Object
Returns the value of attribute last.
4 5 6 |
# File 'lib/bitstamper/models/ticker.rb', line 4 def last @last end |
#low ⇒ Object
Returns the value of attribute low.
4 5 6 |
# File 'lib/bitstamper/models/ticker.rb', line 4 def low @low end |
#open ⇒ Object
Returns the value of attribute open.
4 5 6 |
# File 'lib/bitstamper/models/ticker.rb', line 4 def open @open end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
4 5 6 |
# File 'lib/bitstamper/models/ticker.rb', line 4 def end |
#volume ⇒ Object
Returns the value of attribute volume.
4 5 6 |
# File 'lib/bitstamper/models/ticker.rb', line 4 def volume @volume end |
#vwap ⇒ Object
Returns the value of attribute vwap.
4 5 6 |
# File 'lib/bitstamper/models/ticker.rb', line 4 def vwap @vwap end |
Class Method Details
.parse(data) ⇒ Object
27 28 29 |
# File 'lib/bitstamper/models/ticker.rb', line 27 def self.parse(data) data&.collect { |item| ::Bitstamper::Models::Ticker.new(item) } end |