Class: Mcoin::Command::Ticker
- Defined in:
- lib/mcoin/command/ticker.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#option ⇒ Object
readonly
Returns the value of attribute option.
Instance Method Summary collapse
Methods included from Saveable
Methods included from HasType
Methods included from HasMarket
Methods inherited from Base
description, #initialize, option, #parse!
Constructor Details
This class inherits a constructor from Mcoin::Command::Base
Instance Attribute Details
#option ⇒ Object (readonly)
Returns the value of attribute option.
11 12 13 |
# File 'lib/mcoin/command/ticker.rb', line 11 def option @option end |
Instance Method Details
#execute ⇒ Object
15 16 17 18 19 |
# File 'lib/mcoin/command/ticker.rb', line 15 def execute raise OptionParser::MissingArgument, :market if option.market.nil? print save if save? end |
#markets ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/mcoin/command/ticker.rb', line 30 def markets @markets ||= option.market.map do |name| Market .pick(name) .new(option.type, option.currency) end end |
#print ⇒ Object
21 22 23 24 |
# File 'lib/mcoin/command/ticker.rb', line 21 def print tickers = Parallel.map(markets, :fetch).map(&:to_ticker) Printer.new(tickers).print end |
#save ⇒ Object
26 27 28 |
# File 'lib/mcoin/command/ticker.rb', line 26 def save database.save(markets.map(&:to_ticker).map(&:to_influx)) end |