Class: Navfund::Metrobank
- Defined in:
- lib/navfund/providers/metrobank.rb
Constant Summary collapse
- MAIN_URL =
List of funds
"http://www.metrobank.com.ph/trust_product.asp"
- Funds =
[ {:name => "Money Market Fund", :currency => "PHP", :type => "main"}, {:name => "Max-3 Bond Fund", :currency => "PHP", :type => "main"}, {:name => "Wealth Builder Fund", :currency => "PHP", :type => "main"}, {:name => "Max-5 Bond Fund", :currency => "PHP", :type => "main"}, {:name => "Balanced Fund", :currency => "PHP", :type => "main"}, {:name => "Equity Fund", :currency => "PHP", :type => "main"}, {:name => "$ Money Market Fund", :currency => "USD", :type => "main"}, {:name => "$ Max-3 Bond Fund", :currency => "USD", :type => "main"}, {:name => "$ Max-5 Bond Fund", :currency => "USD", :type => "main"} ]
Instance Method Summary collapse
-
#fund_names ⇒ Object
List supported funds by name.
-
#funds ⇒ Object
List supported funds.
-
#initialize ⇒ Metrobank
constructor
A new instance of Metrobank.
-
#valid_fund?(fund) ⇒ Boolean
Check if the fund name is supported.
-
#value(fund, fund_type = nil) ⇒ Object
Fetch the current value.
Methods inherited from Provider
Constructor Details
Instance Method Details
#fund_names ⇒ Object
List supported funds by name
49 50 51 |
# File 'lib/navfund/providers/metrobank.rb', line 49 def fund_names self.funds.map{ |x| x[:name] } end |
#funds ⇒ Object
List supported funds
44 45 46 |
# File 'lib/navfund/providers/metrobank.rb', line 44 def funds Funds end |
#valid_fund?(fund) ⇒ Boolean
Check if the fund name is supported
54 55 56 |
# File 'lib/navfund/providers/metrobank.rb', line 54 def valid_fund?(fund) self.fund_names.include?(fund) end |
#value(fund, fund_type = nil) ⇒ Object
Fetch the current value
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/navfund/providers/metrobank.rb', line 25 def value(fund, fund_type=nil) val = nil fund_type = fund_type.to_sym if fund_type.is_a?(String) # Set fund_type to nil if VUL page is not present fund_type = nil if fund_type == :vul && @wrapped_vul_document.nil? if valid_fund?(fund) source_document = (fund_type == :vul) ? @wrapped_vul_document : @wrapped_document fname = source_document.search("[text()*='#{fund}']").first if fname fval = fname.parent.next_element rescue nil end val = Provider.strip_value(fval.text) if fval else raise InvalidFund end val end |