Class: TipRanksForecast::Stock
- Inherits:
-
Object
- Object
- TipRanksForecast::Stock
- Defined in:
- lib/tip_ranks_forecast/stock.rb
Constant Summary collapse
- CONSENSUS =
/(\d+)\D+(\d+)\D+(\d+)\D+(\d+)/
Instance Attribute Summary collapse
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Instance Method Summary collapse
- #buy_ratings ⇒ Object
- #high_forecast ⇒ Object
- #hold_ratings ⇒ Object
-
#initialize(symbol) ⇒ Stock
constructor
A new instance of Stock.
- #low_forecast ⇒ Object
- #num_analysts ⇒ Object
- #price_target ⇒ Object
- #sell_ratings ⇒ Object
Constructor Details
#initialize(symbol) ⇒ Stock
Returns a new instance of Stock.
10 11 12 |
# File 'lib/tip_ranks_forecast/stock.rb', line 10 def initialize(symbol) @symbol = symbol.downcase end |
Instance Attribute Details
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
6 7 8 |
# File 'lib/tip_ranks_forecast/stock.rb', line 6 def symbol @symbol end |
Instance Method Details
#buy_ratings ⇒ Object
14 15 16 |
# File 'lib/tip_ranks_forecast/stock.rb', line 14 def search(consensus_data, CONSENSUS, 2).to_i end |
#high_forecast ⇒ Object
18 19 20 |
# File 'lib/tip_ranks_forecast/stock.rb', line 18 def high_forecast currency_int(search(price_target_data, /high forecast of \$([0-9,.]+)/)) end |
#hold_ratings ⇒ Object
22 23 24 |
# File 'lib/tip_ranks_forecast/stock.rb', line 22 def search(consensus_data, CONSENSUS, 3).to_i end |
#low_forecast ⇒ Object
26 27 28 |
# File 'lib/tip_ranks_forecast/stock.rb', line 26 def low_forecast currency_int(search(price_target_data, /low forecast of \$([0-9,.]+)/)) end |
#num_analysts ⇒ Object
30 31 32 |
# File 'lib/tip_ranks_forecast/stock.rb', line 30 def num_analysts search(price_target_data, /Based on (\d+)/).to_i end |
#price_target ⇒ Object
34 35 36 |
# File 'lib/tip_ranks_forecast/stock.rb', line 34 def price_target currency_int(search(price_target_data, /Average Price Target\$([0-9,.]+)/)) end |
#sell_ratings ⇒ Object
38 39 40 |
# File 'lib/tip_ranks_forecast/stock.rb', line 38 def search(consensus_data, CONSENSUS, 4).to_i end |