Class: Finviz::Quote
- Inherits:
-
Object
- Object
- Finviz::Quote
- Defined in:
- lib/finviz/quote.rb
Overview
Single quote representation
Instance Attribute Summary collapse
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
-
#ticker ⇒ Object
readonly
Returns the value of attribute ticker.
Instance Method Summary collapse
- #chart ⇒ Object
-
#initialize(ticker:, stats: nil) ⇒ Quote
constructor
A new instance of Quote.
- #path ⇒ Object
-
#to_h ⇒ Object
grab all instance methods to the hash.
Constructor Details
#initialize(ticker:, stats: nil) ⇒ Quote
Returns a new instance of Quote.
10 11 12 13 |
# File 'lib/finviz/quote.rb', line 10 def initialize(ticker:, stats: nil) @ticker = ticker @stats = ActiveSupport::HashWithIndifferentAccess.new(stats.to_h) end |
Instance Attribute Details
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
8 9 10 |
# File 'lib/finviz/quote.rb', line 8 def stats @stats end |
#ticker ⇒ Object (readonly)
Returns the value of attribute ticker.
8 9 10 |
# File 'lib/finviz/quote.rb', line 8 def ticker @ticker end |
Instance Method Details
#chart ⇒ Object
19 20 21 |
# File 'lib/finviz/quote.rb', line 19 def chart "https://charts2.finviz.com/chart.ashx?t=#{ticker}&ty=c&ta=1&p=d&s=l" end |
#path ⇒ Object
15 16 17 |
# File 'lib/finviz/quote.rb', line 15 def path "https://finviz.com/quote.ashx?t=#{ticker}" end |
#to_h ⇒ Object
grab all instance methods to the hash
24 25 26 27 28 |
# File 'lib/finviz/quote.rb', line 24 def to_h (self.class.instance_methods(false) - [__callee__]).each_with_object({}) do |method, acc| acc[method] = public_send method end end |