Class: Mcoin::Data::Ticker
- Inherits:
-
Object
- Object
- Mcoin::Data::Ticker
- Defined in:
- lib/mcoin/data/ticker.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#ask ⇒ Object
Returns the value of attribute ask.
-
#bid ⇒ Object
Returns the value of attribute bid.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#high ⇒ Object
Returns the value of attribute high.
-
#last ⇒ Object
Returns the value of attribute last.
-
#low ⇒ Object
Returns the value of attribute low.
-
#market ⇒ Object
readonly
Returns the value of attribute market.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#volume ⇒ Object
Returns the value of attribute volume.
Instance Method Summary collapse
-
#initialize(market, type, currency, data = {}) ⇒ Ticker
constructor
A new instance of Ticker.
- #time ⇒ Object
- #to_influx ⇒ Object
Constructor Details
#initialize(market, type, currency, data = {}) ⇒ Ticker
Returns a new instance of Ticker.
10 11 12 13 14 15 16 17 |
# File 'lib/mcoin/data/ticker.rb', line 10 def initialize(market, type, currency, data = {}) @market = market @type = type @currency = currency data.each do |key, value| send("#{key}=", value) end end |
Instance Attribute Details
#ask ⇒ Object
Returns the value of attribute ask.
8 9 10 |
# File 'lib/mcoin/data/ticker.rb', line 8 def ask @ask end |
#bid ⇒ Object
Returns the value of attribute bid.
8 9 10 |
# File 'lib/mcoin/data/ticker.rb', line 8 def bid @bid end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
7 8 9 |
# File 'lib/mcoin/data/ticker.rb', line 7 def currency @currency end |
#high ⇒ Object
Returns the value of attribute high.
8 9 10 |
# File 'lib/mcoin/data/ticker.rb', line 8 def high @high end |
#last ⇒ Object
Returns the value of attribute last.
8 9 10 |
# File 'lib/mcoin/data/ticker.rb', line 8 def last @last end |
#low ⇒ Object
Returns the value of attribute low.
8 9 10 |
# File 'lib/mcoin/data/ticker.rb', line 8 def low @low end |
#market ⇒ Object (readonly)
Returns the value of attribute market.
7 8 9 |
# File 'lib/mcoin/data/ticker.rb', line 7 def market @market end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
8 9 10 |
# File 'lib/mcoin/data/ticker.rb', line 8 def @timestamp end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/mcoin/data/ticker.rb', line 7 def type @type end |
#volume ⇒ Object
Returns the value of attribute volume.
8 9 10 |
# File 'lib/mcoin/data/ticker.rb', line 8 def volume @volume end |
Instance Method Details
#time ⇒ Object
19 20 21 |
# File 'lib/mcoin/data/ticker.rb', line 19 def time Time.at(.to_i).to_s end |
#to_influx ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mcoin/data/ticker.rb', line 23 def to_influx = { type: @type, currency: @currency, market: @market } values = { last: @last, ask: @ask, bid: @bid, low: @low, high: @high, volume: @volume } "prices,#{.map { |t| t.join('=') }.join(',')} " \ "#{values.map { |v| v.join('=') }.join(',')} #{influx_time}" end |