Class: SchwabRb::DataObjects::QuoteFactory
- Inherits:
-
Object
- Object
- SchwabRb::DataObjects::QuoteFactory
- Defined in:
- lib/schwab_rb/data_objects/quote.rb
Class Method Summary collapse
Class Method Details
.build(quote_data) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/schwab_rb/data_objects/quote.rb', line 6 def self.build(quote_data) # Extract the data from nested structure (symbol is the key) symbol = quote_data.keys.first data = quote_data[symbol] data[:symbol] ||= symbol case data[:assetMainType] when "OPTION" OptionQuote.new(data) when "INDEX" IndexQuote.new(data) when "EQUITY" EquityQuote.new(data) else raise "Unknown assetMainType: #{data[:assetMainType]}" end end |