class Navfund::Sunlife
Constants
- Funds
- MAIN_URL
Public Class Methods
new(main_url=nil)
click to toggle source
# File lib/navfund/providers/sunlife.rb, line 21 def initialize(main_url=nil) @url = main_url ||= MAIN_URL @funds = Funds self.scrape end
Public Instance Methods
value(fund, fund_type=nil)
click to toggle source
Fetch the current value
# File lib/navfund/providers/sunlife.rb, line 28 def value(fund, fund_type=nil) val = nil if valid_fund?(fund) fval = fund_table.search("[text()*='#{fund}']").first.next_element.children.last.text rescue nil val = fval.scan(/\d./).join('').to_f if fval else raise InvalidFund end val end
value_at()
click to toggle source
# File lib/navfund/providers/sunlife.rb, line 39 def value_at dtext = fund_table.search("[text()*='As of']").first.text dstr = dtext.split("As of").last.strip Date.strptime(dstr, "%m/%d/%Y") end
Private Instance Methods
fund_table()
click to toggle source
# File lib/navfund/providers/sunlife.rb, line 47 def fund_table @fund_table ||= @wrapped_document.xpath('//div[@id="PesoFunds"]').first end