Slide 47
Slide 47 text
3.2.3 メタプロで定義されたメソッドの場合
https://github.com/roo-rb/roo/blob/v2.10.1/lib/roo/base.rb#L226-L242
# when a method like spreadsheet.a42 is called
# convert it to a call of spreadsheet.cell('a',42)
def method_missing(m, *args)
# #aa42 => #cell('aa',42)
# #aa42('Sheet1') => #cell('aa',42,'Sheet1')
if m =~ /^([a-z]+)(\d+)$/
col = ::Roo::Utils.letter_to_number(Regexp.last_match[1])
row = Regexp.last_match[2].to_i
if args.empty?
cell(row, col)
else
cell(row, col, args.first)
end
else
super
end
end
#a1 や #aa42 といったメソッドが無限に生える