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.



97
98
99
100
101
102
# File 'lib/getFx.rb', line 97

def initialize(curr, date, amt)
  @doc = Nokogiri::HTML(open("https://s3.eu-west-2.amazonaws.com/cq-dev-storage/feed.xml"))
  @curr = curr
  @date = date
  @amt = amt.to_f
end

Instance Method Details

#runComputeObject



104
105
106
107
108
# File 'lib/getFx.rb', line 104

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