Class: Bitstamper::Models::Ticker

Inherits:
Base
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attributes

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

#askObject

Returns the value of attribute ask.



4
5
6
# File 'lib/bitstamper/models/ticker.rb', line 4

def ask
  @ask
end

#bidObject

Returns the value of attribute bid.



4
5
6
# File 'lib/bitstamper/models/ticker.rb', line 4

def bid
  @bid
end

#currency_pairObject

Returns the value of attribute currency_pair.



4
5
6
# File 'lib/bitstamper/models/ticker.rb', line 4

def currency_pair
  @currency_pair
end

#highObject

Returns the value of attribute high.



4
5
6
# File 'lib/bitstamper/models/ticker.rb', line 4

def high
  @high
end

#lastObject

Returns the value of attribute last.



4
5
6
# File 'lib/bitstamper/models/ticker.rb', line 4

def last
  @last
end

#lowObject

Returns the value of attribute low.



4
5
6
# File 'lib/bitstamper/models/ticker.rb', line 4

def low
  @low
end

#openObject

Returns the value of attribute open.



4
5
6
# File 'lib/bitstamper/models/ticker.rb', line 4

def open
  @open
end

#timestampObject

Returns the value of attribute timestamp.



4
5
6
# File 'lib/bitstamper/models/ticker.rb', line 4

def timestamp
  @timestamp
end

#volumeObject

Returns the value of attribute volume.



4
5
6
# File 'lib/bitstamper/models/ticker.rb', line 4

def volume
  @volume
end

#vwapObject

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