Skip to content

Instantly share code, notes, and snippets.

class Bar
class << self
def self.bar(method)
define_method(method) do
puts "Bar.#{method} called."
end
end
bar :foo
bar :baz
class Foo
def self.foo(method)
define_method(method) do
puts "Foo##{method} called."
end
end
foo :bar
foo :baz
end
@shunsugai
shunsugai / compare.rb
Created September 25, 2011 15:58
Test.
#encoding: utf-8
class String
def make_ngram(n)
ary = self.split(//)
ngram_ary = []
p = ary.length
for i in 0..(p - n) do
ngram_ary << ary[i...(i + n)]
end