Class: GetFx::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/getFx.rb

Instance Method Summary collapse

Constructor Details

#initialize(curr, date, amt) ⇒ Parser

Returns a new instance of Parser.



34
35
36
37
38
39
# File 'lib/getFx.rb', line 34

def initialize(curr, date, amt)
  @doc = File.open("feed.xml") { |f| Nokogiri::XML(f) }
  @curr = curr
  @date = date
  @amt = amt.to_f
end

Instance Method Details

#runObject



41
42
43
44
45
# File 'lib/getFx.rb', line 41

def run
  r = @doc.css("[@time='" + @date + "'] > [@currency='" + @curr + "']")[0]["rate"]
  i = r.to_f
  return (i * @amt).round(2)
end