Class: ApmexSilverFinanceYtd
- Inherits:
-
FinanceYtd
- Object
- FinanceYtd
- ApmexSilverFinanceYtd
- Defined in:
- lib/finance-ytd.rb
Instance Attribute Summary
Attributes inherited from FinanceYtd
#css, #css_text, #friendly_name, #symbol, #url, #ytd_return
Instance Method Summary collapse
- #calculate ⇒ Object
-
#initialize(options) ⇒ ApmexSilverFinanceYtd
constructor
A new instance of ApmexSilverFinanceYtd.
- #match ⇒ Object
Methods inherited from FinanceYtd
Constructor Details
#initialize(options) ⇒ ApmexSilverFinanceYtd
Returns a new instance of ApmexSilverFinanceYtd.
92 93 94 95 96 97 98 |
# File 'lib/finance-ytd.rb', line 92 def initialize() super() @css = 'table.table-spot-prices > tbody > tr:nth-child(2) > td:nth-child(2) > span' @url = 'http://www.apmex.com' match() calculate() end |
Instance Method Details
#calculate ⇒ Object
106 107 108 |
# File 'lib/finance-ytd.rb', line 106 def calculate @ytd_return = @price_this_year / @price_last_year - 1.0 end |
#match ⇒ Object
100 101 102 103 104 |
# File 'lib/finance-ytd.rb', line 100 def match super css_text_match = /(\d+\.\d+)/.match(@css_text) @price_this_year = css_text_match[1].gsub(',', '').to_f end |