Created
September 23, 2013 00:44
-
-
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.
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 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