Class: Stockery::Runner
- Inherits:
-
Object
- Object
- Stockery::Runner
- Defined in:
- lib/stockery/runner.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Runner
constructor
A new instance of Runner.
- #run! ⇒ Object
Constructor Details
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/stockery/runner.rb', line 5 def @options end |
Instance Method Details
#run! ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/stockery/runner.rb', line 20 def run! if @options[:quotes].length == 0 abort "Stock symbols missing. Usage `stockery -q \"GOOG, MSFT\"" end s_q = Stockery::Quote.new s_q.source = @options[:source] quotes = @options[:quotes].split(',').collect { |q| q.to_s.strip } quotes_res = [] quotes.each do |quote| quotes_res << s_q.get_status(quote) end case @options[:output] when 'print' puts "Quotes at #{Time.now}\n" puts "" quotes_res.each do |quote| puts s_q.print(quote) puts "\n" end when 'json' puts JSON.generate(quotes_res) end end |