Class: Navfund::Philamlife
- Defined in:
- lib/navfund/providers/philamlife.rb
Constant Summary collapse
- MAIN_URL =
"https://portal.philamlife.com/NAVPU/philamlife"
- Funds =
[ {:name => "PAMI PHILAM BOND FUND", :currency => "PHP", :ticker => "PHILABF:PM"}, {:name => "PAMI PHILAM FUND", :currency => "PHP", :ticker => "PHILAMF:PM"}, {:name => "PAMI PHILAM STRATEGIC GROWTH FUND", :currency => "PHP", :ticker => "PHILSTG:PM"}, {:name => "PESO FIXED INCOME FUND", :currency => "PHP", :ticker => ""}, {:name => "PESO EQUITY FUND", :currency => "PHP", :ticker => ""}, {:name => "PESO BALANCED FUND", :currency => "PHP", :ticker => ""}, {:name => "DOLLAR BOND FUND", :currency => "USD", :ticker => ""}, {:name => "DOLLAR GLOBAL BOND FUND", :currency => "USD", :ticker => ""}, {:name => "DOLLAR HIGH-WATER MARK FUND 2019", :currency => "USD", :ticker => ""}, {:name => "PRINCIPAL PROTECT FUND 1", :currency => "PHP", :ticker => ""}, {:name => "PRINCIPAL PROTECT FUND 2", :currency => "PHP", :ticker => ""}, {:name => "PRINCIPAL PROTECT EMERGING MARKETS FUND", :currency => "PHP", :ticker => ""}, {:name => "ASIA'S BEST FUND 1", :currency => "PHP", :ticker => ""}, {:name => "ASIA'S BEST FUND 2", :currency => "PHP", :ticker => ""}, {:name => "GROWTH INVEST FUND 1", :currency => "PHP", :ticker => ""}, {:name => "GROWTH INVEST FUND 2", :currency => "PHP", :ticker => ""}, {:name => "GROWTH INVEST FUND 3", :currency => "PHP", :ticker => ""} ]
Instance Attribute Summary
Attributes inherited from Provider
Instance Method Summary collapse
- #find_fund_node(doc, fund) ⇒ Object
-
#initialize(main_url = nil) ⇒ Philamlife
constructor
A new instance of Philamlife.
-
#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
#initialize(main_url = nil) ⇒ Philamlife
Returns a new instance of Philamlife.
26 27 28 29 30 |
# File 'lib/navfund/providers/philamlife.rb', line 26 def initialize(main_url=nil) @url = main_url ||= MAIN_URL @funds = Funds self.scrape(:check_ssl => false) end |
Instance Method Details
#find_fund_node(doc, fund) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/navfund/providers/philamlife.rb', line 51 def find_fund_node(doc, fund) fname = nil if fund.match(/'/) # Fund name contains apostrophe, iterate nodeset and compare text instead tfund = fund.split('\'').last doc.search("[text()*='#{tfund}']").each do |tn| fname = tn if tn.text == fund end else fname = doc.search("[text()*='#{fund}']").first end fname end |
#value(fund, fund_type = nil) ⇒ Object
Fetch the current value
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/navfund/providers/philamlife.rb', line 33 def value(fund, fund_type=nil) val = nil if valid_fund?(fund) fname = find_fund_node(@wrapped_document, fund) fval = fname.parent.next_element rescue nil val = Provider.strip_value(fval.text) if fval else raise InvalidFund end val end |
#value_at ⇒ Object
45 46 47 48 49 |
# File 'lib/navfund/providers/philamlife.rb', line 45 def value_at dcontainer = @wrapped_document.search('div#detailcol3').first dtext = dcontainer.text.strip Date.strptime(dtext, "%m/%d/%Y") end |