2008-03-25から1日間の記事一覧

西尾泰和のブログ: RubyのyieldとPythonのyieldの違い

RubyのyieldとPythonのyieldは実は全然違うような気がしてきたので、整理のために書いてみます。 まず、Rubyでeachに相当する物を自分で実装してみました。 # Ruby 1 class Array def my_each self.each{|x| yield x } end end [1, 2, 3, 4, 5].my_each{|x| …

Ruby-style mixins in PHP

This is a rather hackish way to accomplish something resembling ruby’s mixins, I doubt it we will ever be able to do this as elegantly as in ruby. This is the closest I can come to true mixins, without using ext/runkit.

Rubyを使ってPaSoRi経由でSuicaの乗車履歴を取得し、GoogleMapsやGoogleEarthで表示する

def Pasori.parse_suica_raw_value data d = "%016b" % data[8, 4].hex { :type => data[0, 2], :date => Time.local(d[0, 7].to_i(2) + 2000, d[7, 4].to_i(2), d[11, 5].to_i(2)), :in => data[12, 4], :out => data[16, 4], :yen => data[20, 2].hex + (d…

Rubyを使ってPaSoRi経由でSuicaの乗車履歴を取得し、GoogleMapsやGoogleEarthで表示する

def Pasori.parse_suica_raw_value data d = "%016b" % data[8, 4].hex { :type => data[0, 2], :date => Time.local(d[0, 7].to_i(2) + 2000, d[7, 4].to_i(2), d[11, 5].to_i(2)), :in => data[12, 4], :out => data[16, 4], :yen => data[20, 2].hex + (d…

JavaとRubyの共通点と相違点 − @IT自分戦略研究所

http://jibun.atmarkit.co.jp/lskill01/rensai/jruby02/jruby01.html http://b.hatena.ne.jp/entry/http://jibun.atmarkit.co.jp/lskill01/rensai/jruby02/jruby01.html