Class: Ruboty::Handlers::Fx

Inherits:
Base
  • Object
show all
Defined in:
lib/ruboty/handlers/fx.rb

Constant Summary collapse

YFX_URL =
'http://info.finance.yahoo.co.jp/fx/async/getRate/'

Instance Method Summary collapse

Instance Method Details

#fx(message = {}) ⇒ Object



11
12
13
14
15
16
# File 'lib/ruboty/handlers/fx.rb', line 11

def fx(message = {})
  pair = message[:pair].gsub('/','').gsub(/\s/,'')
  message.reply(rate_to_s(get_json[pair], pair))
rescue
  message.reply('Unknow error.')
end

#list(m = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/ruboty/handlers/fx.rb', line 18

def list(m = {})
  str = get_json.map do |pair, state|
    rate_to_s(state, pair)
  end.join("\n")

  m.reply("```\n#{str}\n```")
rescue
  m.reply('Unknow error.')
end