Created
July 17, 2015 13:05
-
-
Save eltercero/20ad18c8d865549617bc to your computer and use it in GitHub Desktop.
Snippet for creating a class with its attributes
This file contains 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
<!-- | |
Easily creates something like: | |
class Object | |
attr_reader :attr1, :attr2, :attr3 | |
def initialize attr1, attr2, attr3 | |
@attr1 = attr1 | |
@attr2 = attr2 | |
@attr3 = attr3 | |
end | |
end | |
--> | |
<snippet> | |
<content><![CDATA[ | |
class ${1:${TM_FILENAME/(?:\A|_)([A-Za-z0-9]+)(?:\.rb)?/(?2::\u$1)/g}} | |
attr_reader ${2/(\w)+/:$MATCH/g} | |
def initialize $2 | |
${2/(\w)+|,(\s)?/(?1@$MATCH = $MATCH)(?2\n\t\t)/g} | |
end | |
end | |
]]></content> | |
<tabTrigger>kla</tabTrigger> | |
<scope>source.ruby</scope> | |
</snippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment