Update ruby snippets
This commit is contained in:
parent
3406aca82a
commit
25be45de10
@ -1,11 +1,10 @@
|
|||||||
snippet #! "#!/usr/bin/env ruby"
|
snippet "^#!" "#!/usr/bin/env ruby" r
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
$0
|
$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
snippet "^# ?[uU][tT][fF]-?8" "# encoding: UTF-8" r
|
||||||
snippet #utf8 "# encoding: UTF-8"
|
|
||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
$0
|
$0
|
||||||
endsnippet
|
endsnippet
|
||||||
@ -13,13 +12,13 @@ endsnippet
|
|||||||
|
|
||||||
|
|
||||||
snippet If "<command> if <expression>"
|
snippet If "<command> if <expression>"
|
||||||
${1:command} if ${2:expression$0}
|
${1:command} if ${0:expression}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet Unless "<command> unless <expression>"
|
snippet Unless "<command> unless <expression>"
|
||||||
${1:command} unless ${2:expression$0}
|
${1:command} unless ${0:expression}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +26,7 @@ endsnippet
|
|||||||
snippet if "if <condition> ... end"
|
snippet if "if <condition> ... end"
|
||||||
if ${1:condition}
|
if ${1:condition}
|
||||||
${2:# TODO}
|
${2:# TODO}
|
||||||
end${3:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ if ${1:condition}
|
|||||||
${2:# TODO}
|
${2:# TODO}
|
||||||
else
|
else
|
||||||
${3:# TODO}
|
${3:# TODO}
|
||||||
end${4:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
@ -48,16 +47,16 @@ if ${1:condition}
|
|||||||
elsif ${3:condition}
|
elsif ${3:condition}
|
||||||
${4:# TODO}
|
${4:# TODO}
|
||||||
else
|
else
|
||||||
${5:# TODO}
|
${0:# TODO}
|
||||||
end${6:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet unless "unless <condition> ... end"
|
snippet unless "unless <condition> ... end"
|
||||||
unless ${1:condition}
|
unless ${1:condition}
|
||||||
${2:# TODO}
|
${0:# TODO}
|
||||||
end${3:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
@ -66,8 +65,8 @@ snippet unlesse "unless <condition> ... else ... end"
|
|||||||
unless ${1:condition}
|
unless ${1:condition}
|
||||||
${2:# TODO}
|
${2:# TODO}
|
||||||
else
|
else
|
||||||
${3:# TODO}
|
${0:# TODO}
|
||||||
end${4:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
@ -78,15 +77,15 @@ unless ${1:condition}
|
|||||||
elsif ${3:condition}
|
elsif ${3:condition}
|
||||||
${4:# TODO}
|
${4:# TODO}
|
||||||
else
|
else
|
||||||
${5:# TODO}
|
${0:# TODO}
|
||||||
end${6:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "\b(de)?f" "def <name>..." r
|
snippet "\b(de)?f" "def <name>..." r
|
||||||
def ${1:function_name}${2: ${3:*args}}
|
def ${1:function_name}${2: ${3:*args}}
|
||||||
${4:# TODO$0}
|
${0:# TODO}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -94,7 +93,7 @@ endsnippet
|
|||||||
|
|
||||||
snippet defi "def initialize ..."
|
snippet defi "def initialize ..."
|
||||||
def initialize${1: ${2:*args}}
|
def initialize${1: ${2:*args}}
|
||||||
${3:# TODO$0}
|
${0:# TODO}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -104,153 +103,168 @@ snippet defr "def <name> ... rescue ..."
|
|||||||
def ${1:function_name}${2: ${3:*args}}
|
def ${1:function_name}${2: ${3:*args}}
|
||||||
${4:# TODO}
|
${4:# TODO}
|
||||||
rescue
|
rescue
|
||||||
${5:# TODO}
|
${0:# TODO}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet For "(<from>..<to>).each { |<i>| <block> }"
|
snippet For "(<from>..<to>).each { |<i>| <block> }"
|
||||||
(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} }${5:$0}
|
(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet for "(<from>..<to>).each do |<i>| <block> end"
|
snippet for "(<from>..<to>).each do |<i>| <block> end"
|
||||||
(${1:from}..${2:to}).each do |${3:i}|
|
(${1:from}..${2:to}).each do |${3:i}|
|
||||||
${4:# TODO}
|
${0:# TODO}
|
||||||
end${5:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Merge!" ".merge!(<other_hash>) { |<key>,<oldval>,<newval>| <block> }" r
|
snippet "(\S+)\.Merge!" ".merge!(<other_hash>) { |<key>,<oldval>,<newval>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) { |${2:key},${3:oldval},${4:newval}| ${5:block} }${6:$0}
|
`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) { |${2:key},${3:oldval},${4:newval}| ${5:block} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.merge!" ".merge!(<other_hash>) do |<key>,<oldval>,<newval>| <block> end" r
|
snippet "(\S+)\.merge!" ".merge!(<other_hash>) do |<key>,<oldval>,<newval>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) do |${2:key},${3:oldval},${4:newval}|
|
`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) do |${2:key},${3:oldval},${4:newval}|
|
||||||
${5:block}
|
${0:block}
|
||||||
end${6:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Delete_?if" ".delete_if { |<key>,<value>| <block> }" r
|
snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |<key>,<value>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3:# TODO} }${4:$0}
|
`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3:# TODO} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.delete_?if" ".delete_if do |<key>,<value>| <block> end" r
|
snippet "(\S+)\.del(ete)?_?if" ".delete_if do |<key>,<value>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.delete_if do |${1:key},${2:value}|
|
`!p snip.rv=match.group(1)`.delete_if do |${1:key},${2:value}|
|
||||||
${3:# TODO}
|
${0:# TODO}
|
||||||
end${4:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Keep_?if" ".keep_if { |<key>,<value>| <block> }" r
|
snippet "(\S+)\.Keep_?if" ".keep_if { |<key>,<value>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3:# TODO} }${4:$0}
|
`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3:# TODO} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.keep_?if" ".keep_if do <key>,<value>| <block> end" r
|
snippet "(\S+)\.keep_?if" ".keep_if do <key>,<value>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}|
|
`!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}|
|
||||||
${3:# TODO}
|
${0:# TODO}
|
||||||
end${4:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Reject" ".reject { |<key>,<value>| <block> }" r
|
snippet "(\S+)\.Reject" ".reject { |<key>,<value>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3:# TODO} }${4:$0}
|
`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3:# TODO} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.reject" ".reject do <key>,<value>| <block> end" r
|
snippet "(\S+)\.reject" ".reject do <key>,<value>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}|
|
`!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}|
|
||||||
${3:# TODO}
|
${0:# TODO}
|
||||||
end${4:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Select" ".select { |<item>| <block>}" r
|
snippet "(\S+)\.Select" ".select { |<item>| <block>}" r
|
||||||
`!p snip.rv=match.group(1)`.select { |${1:item}| ${2:block} }${3:$0}
|
`!p snip.rv=match.group(1)`.select { |${1:item}| ${2:block} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.select" ".select do |<item>| <block> end" r
|
snippet "(\S+)\.select" ".select do |<item>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.select do |${1:item}|
|
`!p snip.rv=match.group(1)`.select do |${1:item}|
|
||||||
${2:block}
|
${0:block}
|
||||||
end${3:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Sort" ".sort { |<a>,<b>| <block> }" i
|
snippet "(\S+)\.Sort" ".sort { |<a>,<b>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.sort { |${1:a},${2,b}| ${3:# TODO} }${4:$0}
|
`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3:# TODO} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.sort" ".sort do |<a>,<b>| <block> end" r
|
snippet "(\S+)\.sort" ".sort do |<a>,<b>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.sort do |${1:a},${2,b}|
|
`!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}|
|
||||||
${3:# TODO}
|
${0:# TODO}
|
||||||
end${4:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Each_?key" ".each_key { |<key>| <block> }" r
|
snippet "(\S+)\.Each_?k(ey)?" ".each_key { |<key>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2:# TODO} }${3:$0}
|
`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2:# TODO} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.each_?key" ".each_key do |key| <block> end" r
|
snippet "(\S+)\.each_?k(ey)?" ".each_key do |key| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.each_key do |${1:key}|
|
`!p snip.rv=match.group(1)`.each_key do |${1:key}|
|
||||||
${2:# TODO}
|
${0:# TODO}
|
||||||
end${3:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Each_?value" ".each_value { |<value>| <block> }" r
|
snippet "(\S+)\.Each_?val(ue)?" ".each_value { |<value>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2:# TODO} }${3:$0}
|
`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2:# TODO} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.each_?value" ".each_value do |<value>| <block> end" r
|
snippet "(\S+)\.each_?val(ue)?" ".each_value do |<value>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.each_value do |${1:value}|
|
`!p snip.rv=match.group(1)`.each_value do |${1:value}|
|
||||||
${2:# TODO}
|
${0:# TODO}
|
||||||
end${3:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet Each "<elements>.each { |<element>| <block> }"
|
snippet Each "<elements>.each { |<element>| <block> }"
|
||||||
${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} }${4:$0}
|
${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet each "<elements>.each do |<element>| <block> end"
|
snippet each "<elements>.each do |<element>| <block> end"
|
||||||
${1:elements}.each do |${2:${1/s$//}}|
|
${1:elements}.each do |${2:${1/s$//}}|
|
||||||
${3:# TODO}
|
${0:# TODO}
|
||||||
end${4:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Map" ".map { |<element>| <block> }" r
|
snippet each_?s(lice)? "<array>.each_slice(n) do |slice| <block> end"
|
||||||
|
each_slice(${1:2}) do |${2:slice}|
|
||||||
|
${0:# TODO}
|
||||||
|
end
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
snippet Each_?s(lice)? "<array>.each_slice(n) { |slice| <block> }"
|
||||||
|
each_slice(${1:2}) { |${2:slice}| ${3:# TODO} }
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
snippet "(\S+)\.Map" ".map { |<element>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.map { |${1:`!p
|
`!p snip.rv=match.group(1)`.map { |${1:`!p
|
||||||
element_name = match.group(1).lstrip('$@')
|
element_name = match.group(1).lstrip('$@')
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
||||||
@ -259,12 +273,12 @@ try:
|
|||||||
snip.rv = wmatch.group(1).lower()
|
snip.rv = wmatch.group(1).lower()
|
||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`}| ${2:# TODO} }${3:$0}
|
`}| ${2:# TODO} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.map" ".map do |<element>| <block> end" r
|
snippet "(\S+)\.map" ".map do |<element>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.map do |${1:`!p
|
`!p snip.rv=match.group(1)`.map do |${1:`!p
|
||||||
element_name = match.group(1).lstrip('$@')
|
element_name = match.group(1).lstrip('$@')
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
||||||
@ -274,13 +288,13 @@ try:
|
|||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`}|
|
`}|
|
||||||
${2:# TODO}
|
${0:# TODO}
|
||||||
end${3:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Reverse_?each" ".reverse_each { |<element>| <block> }" r
|
snippet "(\S+)\.Rev(erse)?_?each" ".reverse_each { |<element>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.reverse_each { |${1:`!p
|
`!p snip.rv=match.group(1)`.reverse_each { |${1:`!p
|
||||||
element_name = match.group(1).lstrip('$@')
|
element_name = match.group(1).lstrip('$@')
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
||||||
@ -289,12 +303,12 @@ try:
|
|||||||
snip.rv = wmatch.group(1).lower()
|
snip.rv = wmatch.group(1).lower()
|
||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`}| ${2:# TODO} }${3:$0}
|
`}| ${2:# TODO} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.reverse_?each" ".reverse_each do |<element>| <block> end" r
|
snippet "(\S+)\.rev(erse)?_?each" ".reverse_each do |<element>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.reverse_each do |${1:`!p
|
`!p snip.rv=match.group(1)`.reverse_each do |${1:`!p
|
||||||
element_name = match.group(1).lstrip('$@')
|
element_name = match.group(1).lstrip('$@')
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
||||||
@ -304,13 +318,13 @@ try:
|
|||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`}|
|
`}|
|
||||||
${2:# TODO}
|
${0:# TODO}
|
||||||
end${3:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Each" ".each { |<element>| <block> }" r
|
snippet "(\S+)\.Each" ".each { |<element>| <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.each { |${1:`!p
|
`!p snip.rv=match.group(1)`.each { |${1:`!p
|
||||||
element_name = match.group(1).lstrip('$@')
|
element_name = match.group(1).lstrip('$@')
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
||||||
@ -319,12 +333,12 @@ try:
|
|||||||
snip.rv = wmatch.group(1).lower()
|
snip.rv = wmatch.group(1).lower()
|
||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`}| ${2:# TODO} }${3:$0}
|
`}| ${2:# TODO} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.each" ".each do |<element>| <block> end" r
|
snippet "(\S+)\.each" ".each do |<element>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.each do |${1:`!p
|
`!p snip.rv=match.group(1)`.each do |${1:`!p
|
||||||
element_name = match.group(1).lstrip('$@')
|
element_name = match.group(1).lstrip('$@')
|
||||||
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
||||||
@ -334,55 +348,87 @@ try:
|
|||||||
except:
|
except:
|
||||||
snip.rv = 'element'
|
snip.rv = 'element'
|
||||||
`}|
|
`}|
|
||||||
${2:# TODO}
|
${0:# TODO}
|
||||||
end${3:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Each_?index" ".each_index { |<index>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.each_index { |${1:index}| ${2:# TODO} }${3:$0}
|
snippet "(\S+)\.Each_w(ith)?_?i(ndex)?" ".each_with_index { |<element>,<i>| <block> }" r
|
||||||
|
`!p snip.rv=match.group(1)`.each_with_index { |${1:`!p
|
||||||
|
element_name = match.group(1).lstrip('$@')
|
||||||
|
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
||||||
|
try:
|
||||||
|
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
|
||||||
|
snip.rv = wmatch.group(1).lower()
|
||||||
|
except:
|
||||||
|
snip.rv = 'element'
|
||||||
|
`},${2:i}| ${3:# TODO} }$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.each_?index" ".each_index do |<index>| <block> end" r
|
snippet "(\S+)\.each_?w(ith)?_?i(ndex)?" ".each_with_index do |<element>,<i>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.each_index do |${1:index}|
|
`!p snip.rv=match.group(1)`.each_with_index do |${1:`!p
|
||||||
${2:# TODO}
|
element_name = match.group(1).lstrip('$@')
|
||||||
end${3:$0}
|
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
|
||||||
|
try:
|
||||||
|
wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1))
|
||||||
|
snip.rv = wmatch.group(1).lower()
|
||||||
|
except:
|
||||||
|
snip.rv = 'element'
|
||||||
|
`},${2:i}|
|
||||||
|
${0:# TODO}
|
||||||
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.Each_?pair" ".each_pair { |<key>,<value>| <block> }" r
|
|
||||||
`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3:# TODO} }${4:$0}
|
snippet "(\S+)\.Each_?p(air)?" ".each_pair { |<key>,<value>| <block> }" r
|
||||||
|
`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3:# TODO} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.each_?pair" ".each_pair do |<key>,<value>| <block> end" r
|
snippet "(\S+)\.each_?p(air)?" ".each_pair do |<key>,<value>| <block> end" r
|
||||||
`!p snip.rv=match.group(1)`.each_pair do |${1:key},${2:value}|
|
`!p snip.rv=match.group(1)`.each_pair do |${1:key},${2:value}|
|
||||||
${3:# TODO}
|
${0:# TODO}
|
||||||
end${4:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.sub" ".sub(<expression>) { <block> }" r
|
snippet "(\S+)\.sub" ".sub(<expression>) { <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.sub(${1:expression}) { ${2:"replace_with"} }${3:$0}
|
`!p snip.rv=match.group(1)`.sub(${1:expression}) { ${2:"replace_with"} }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet "([^ \t]+)\.gsub" ".gsub(<expression>) { <block> }" r
|
snippet "(\S+)\.gsub" ".gsub(<expression>) { <block> }" r
|
||||||
`!p snip.rv=match.group(1)`.gsub(${1:expression}) { ${2:"replace_with"} }${3:$0}
|
`!p snip.rv=match.group(1)`.gsub(${1:expression}) { ${2:"replace_with"} }
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
snippet "(\S+)\.index" ".index { |item| <block> }" r
|
||||||
|
`!p snip.rv=match.group(1)`.index { |${1:item}| ${2:block} }
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
snippet "(\S+)\.Index" ".index do |item| ... end" r
|
||||||
|
`!p snip.rv=match.group(1)`.index do |${1:item}|
|
||||||
|
${0:block}
|
||||||
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet do "do |<key>| ... end" i
|
snippet do "do |<key>| ... end" i
|
||||||
do ${1:|${2:key}|}
|
do ${1:|${2:key}|}
|
||||||
${3:$0}
|
$0
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -390,76 +436,57 @@ endsnippet
|
|||||||
|
|
||||||
snippet Do "do ... end" i
|
snippet Do "do ... end" i
|
||||||
do
|
do
|
||||||
${1:$0}
|
$0
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
snippet until "until <expression> ... end"
|
snippet until "until <expression> ... end"
|
||||||
until ${1:expression}
|
until ${1:expression}
|
||||||
${2:# TODO}
|
${0:# TODO}
|
||||||
end${3:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet Until "begin ... end until <expression>"
|
snippet Until "begin ... end until <expression>"
|
||||||
begin
|
begin
|
||||||
${2:# TODO}
|
${0:# TODO}
|
||||||
end until ${1:expression}${3:$0}
|
end until ${1:expression}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet while "while <expression> ... end"
|
snippet while "while <expression> ... end"
|
||||||
while ${1:expression}
|
while ${1:expression}
|
||||||
${2:# TODO}
|
${0:# TODO}
|
||||||
end${3:$0}
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet While "begin ... end while <expression>"
|
snippet While "begin ... end while <expression>"
|
||||||
begin
|
begin
|
||||||
${2:# TODO}
|
${0:# TODO}
|
||||||
end while ${1:expression}${3:$0}
|
end while ${1:expression}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet r "attr_reader :<attr_names>"
|
snippet "\b(r|attr)" "attr_reader :<attr_names>" r
|
||||||
attr_reader :${1:attr_names}
|
attr_reader :${0:attr_names}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet w "attr_writer :<attr_names>"
|
snippet "\b(w|attr)" "attr_writer :<attr_names>" r
|
||||||
attr_writer :${1:attr_names}
|
attr_writer :${0:attr_names}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet w "attr_accessor :<attr_names>"
|
snippet "\b(rw|attr)" "attr_accessor :<attr_names>" r
|
||||||
snippet rw
|
attr_accessor :${0:attr_names}
|
||||||
attr_accessor :${1:attr_names}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet attr "attr_reader :<attr_names>"
|
|
||||||
attr_reader :${1:attr_names}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet attr "attr_writer :<attr_names>"
|
|
||||||
attr_writer :${1:attr_names}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet attr "attr_accessor :<attr_names>"
|
|
||||||
attr_accessor :${1:attr_names}
|
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
@ -468,7 +495,7 @@ snippet begin "begin ... rescue ... end"
|
|||||||
begin
|
begin
|
||||||
${1:# TODO}
|
${1:# TODO}
|
||||||
rescue
|
rescue
|
||||||
${2:# TODO}
|
${0:# TODO}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -484,7 +511,7 @@ rescue Exception => e
|
|||||||
else
|
else
|
||||||
${3:# other exception}
|
${3:# other exception}
|
||||||
ensure
|
ensure
|
||||||
${4:# always excute}
|
${0:# always excute}
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -494,15 +521,15 @@ snippet rescue
|
|||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
puts e.message
|
puts e.message
|
||||||
puts e.backtrace.inspect
|
puts e.backtrace.inspect
|
||||||
${1:# Rescue}
|
${0:# Rescue}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snippet case "case <variable> when <expression> ... end"
|
snippet "\b(case|sw(itch)?)" "case <variable> when <expression> ... end" r
|
||||||
case ${1:variable}
|
case ${1:variable}
|
||||||
when ${2:expression}
|
when ${2:expression}
|
||||||
${3:$0}
|
$0
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
@ -516,9 +543,26 @@ endsnippet
|
|||||||
|
|
||||||
snippet class "class <class_name> def initialize ... end end"
|
snippet class "class <class_name> def initialize ... end end"
|
||||||
class ${1:class_name}
|
class ${1:class_name}
|
||||||
${2:def initialize ${3:*args}
|
def initialize ${2:*args}
|
||||||
${4}
|
$0
|
||||||
end}
|
end
|
||||||
|
end
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
snippet module "module"
|
||||||
|
module ${1:module_name}
|
||||||
$0
|
$0
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
snippet ###
|
||||||
|
=begin
|
||||||
|
$0
|
||||||
|
=end
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2 expandtab:
|
||||||
|
Loading…
Reference in New Issue
Block a user