Class: Navfund::Sunlife
- Defined in:
- lib/navfund/providers/sunlife.rb
Constant Summary collapse
- MAIN_URL =
"http://www.sunlife.com.ph/philippines/Products+and+Services/Sun+Life+Prosperity+Funds?vgnLocale=en_CA"- Funds =
[ {:name => "Bond Fund", :currency => "PHP", :ticker => "SNCPRBF:PM"}, {:name => "Balanced Fund", :currency => "PHP", :ticker => "SNCPRBA:PM"}, {:name => "Equity Fund", :currency => "PHP", :ticker => "SNCPPEA:PM"}, {:name => "Money Market Fund", :currency => "PHP", :ticker => "SNLFMNY:PM"}, {:name => "GS Fund", :currency => "PHP", :ticker => "SNLPRGS:PM"}, {:name => "Dollar Advantage Fund", :currency => "USD", :ticker => "SUNPDAA:PM"}, {:name => "Dollar Abundance Fund", :currency => "USD", :ticker => "SNLPRDA:PM"} ]
Instance Attribute Summary
Attributes inherited from Provider
Instance Method Summary collapse
-
#initialize(main_url = nil) ⇒ Sunlife
constructor
A new instance of Sunlife.
-
#value(fund, fund_type = nil) ⇒ Object
Fetch the current value.
- #value_at ⇒ Object
Methods inherited from Provider
#fund_names, #fund_values, #scrape, strip_value, #uitf_com_ph_date_parser, #uitf_com_ph_parser, #valid_fund?
Constructor Details
Instance Method Details
#value(fund, fund_type = nil) ⇒ Object
Fetch the current value
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/navfund/providers/sunlife.rb', line 23 def value(fund, fund_type=nil) val = nil if valid_fund?(fund) fname = @wrapped_document.search("[text()*='#{fund}']").first fval = fname.parent.next_element rescue nil val = Provider.strip_value(fval.text) if fval else raise InvalidFund end val end |
#value_at ⇒ Object
35 36 37 38 39 40 |
# File 'lib/navfund/providers/sunlife.rb', line 35 def value_at dcontainer = @wrapped_document.search("div.newsHeadlineTitle[align='left']").first dtext = dcontainer.text dstr = dtext.split("As of").last.strip Date.strptime(dstr, "%m/%d/%Y") end |