Skip to content

Instantly share code, notes, and snippets.

@tehprofessor
Created September 23, 2013 00:44
Show Gist options
  • Save tehprofessor/6665321 to your computer and use it in GitHub Desktop.
Save tehprofessor/6665321 to your computer and use it in GitHub Desktop.
Handy little shortcut for OpalRB, adds #to_element method (and #to_e via an alias) to String.
class String
def to_element
Element.find("#{self}")
end
alias :to_e :to_element
end
# Now you can do:
el = "#cool-stuff".to_e
# vs
el = Element.find("#cool-stuff")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment