Skip to content

Instantly share code, notes, and snippets.

@koduki
Created June 15, 2011 02:38
Show Gist options
  • Save koduki/1026375 to your computer and use it in GitHub Desktop.
Save koduki/1026375 to your computer and use it in GitHub Desktop.
# -*- encoding: UTF-8 -*-
require 'time'
require 'twitter'
require 'roma/client'
timeline = Twitter.user_timeline('ntt_rate1').map{|s| [s.id, s.text, Time.parse(s.created_at)]}
rates = timeline.map do |r|
[
r[0],
r[1].scan(/ドル\/円:(.*?)円、ユーロ\/円:(.*?)円、ポンド\/円:(.*?)円、豪ドル\/円:(.*?)円/).flatten.map{|x| x.to_f},
r[2],
]
end
table = Roma::Client::RomaClient.new(['localhost:11212', 'localhost:11212'])
rates.each do |rate|
table[rate.first.to_s] = {USD:rate[1][0], EUR:rate[1][1], GBP:rate[1][2], AUD:rate[1][2], date:rate[2]}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment