Skip to content

Instantly share code, notes, and snippets.

View pootsbook's full-sized avatar

Philip Poots pootsbook

  • ClubCollect
  • Alphen aan den Rijn, NL
View GitHub Profile
@pootsbook
pootsbook / gist:1583368
Created January 9, 2012 15:18
Ever wanted Array#penultimate? How about Array#penpenultimate
class Array
def method_missing(method_sym, *arguments, &block)
if method_sym.to_s =~ /^((pen)+)ultimate$/
pen_index = 1 + ($1.length/3)
self[-pen_index]
else
super
end
end
end