This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bar | |
class << self | |
def self.bar(method) | |
define_method(method) do | |
puts "Bar.#{method} called." | |
end | |
end | |
bar :foo | |
bar :baz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def self.foo(method) | |
define_method(method) do | |
puts "Foo##{method} called." | |
end | |
end | |
foo :bar | |
foo :baz | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
NewerOlder