Class: Yahoo::Stock
- Inherits:
-
Object
- Object
- Yahoo::Stock
- Defined in:
- lib/yahoo_stock.rb,
lib/yahoo_stock/base.rb,
lib/yahoo_stock/query.rb
Defined Under Namespace
Classes: Query
Constant Summary collapse
- BASE_URI =
'http://au.finance.yahoo.com/q?s='
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
-
#initialize(stock_code) ⇒ Stock
constructor
A new instance of Stock.
-
#last_trade ⇒ Object
Deprecated methods.
- #last_trade_date ⇒ Object
- #last_trade_price ⇒ Object
- #last_trade_time ⇒ Object
- #last_trade_time_new ⇒ Object
Constructor Details
#initialize(stock_code) ⇒ Stock
Returns a new instance of Stock.
5 6 7 |
# File 'lib/yahoo_stock/base.rb', line 5 def initialize(stock_code) @code = stock_code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/yahoo_stock/base.rb', line 3 def code @code end |
Instance Method Details
#last_trade ⇒ Object
Deprecated methods
29 30 31 |
# File 'lib/yahoo_stock/base.rb', line 29 def last_trade get_info.at(".yfnc_tabledata1").inner_text end |
#last_trade_date ⇒ Object
23 24 25 26 |
# File 'lib/yahoo_stock/base.rb', line 23 def last_trade_date t = Time.parse last_trade_time t.strftime "%d %B %Y" end |
#last_trade_price ⇒ Object
9 10 11 |
# File 'lib/yahoo_stock/base.rb', line 9 def last_trade_price sprintf "%0.2f", get_info.at(".yfnc_tabledata1").inner_text.to_f end |
#last_trade_time ⇒ Object
33 34 35 |
# File 'lib/yahoo_stock/base.rb', line 33 def last_trade_time get_info.search(".yfnc_tabledata1")[1].inner_text end |
#last_trade_time_new ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/yahoo_stock/base.rb', line 13 def last_trade_time_new # 'close of trade' if time not present t = Time.parse last_trade_time if [t.hour, t.min, t.sec] == [0,0,0] 'close of trade' else "#{t.hour}:#{t.min}" end end |