Skip to content

Instantly share code, notes, and snippets.

@pootsbook
Created January 9, 2012 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pootsbook/1583368 to your computer and use it in GitHub Desktop.
Save pootsbook/1583368 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment