Permalink
Browse files

Add more ruby snippets

  • Loading branch information...
1 parent dfc3f78 commit 876125a09633e6497c293a0e09428caa0954b8e3 @graudeejs committed Sep 29, 2012
Showing with 80 additions and 24 deletions.
  1. +80 −24 snippets/ruby/ruby.snippets
View
@@ -28,7 +28,7 @@ endsnippet
snippet if "if <condition> ... end"
if ${1:condition}
- ${2:# TODO}
+ ${0:# TODO}
end
endsnippet
@@ -38,7 +38,7 @@ snippet ife "if <condition> ... else ... end"
if ${1:condition}
${2:# TODO}
else
- ${3:# TODO}
+ ${0:# TODO}
end
endsnippet
@@ -113,7 +113,7 @@ endsnippet
snippet For "(<from>..<to>).each { |<i>| <block> }"
-(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} }
+(${1:from}..${2:to}).each { |${3:i}| $4 }
endsnippet
@@ -141,7 +141,7 @@ endsnippet
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} }
+`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| $3 }
endsnippet
@@ -155,7 +155,7 @@ endsnippet
snippet "(\S+)\.Keep_?if" ".keep_if { |<key>,<value>| <block> }" r
-`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3:# TODO} }
+`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| $3 }
endsnippet
@@ -169,7 +169,7 @@ endsnippet
snippet "(\S+)\.Reject" ".reject { |<key>,<value>| <block> }" r
-`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3:# TODO} }
+`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| $3 }
endsnippet
@@ -183,7 +183,7 @@ endsnippet
snippet "(\S+)\.Select" ".select { |<item>| <block>}" r
-`!p snip.rv=match.group(1)`.select { |${1:item}| ${2:block} }
+`!p snip.rv=match.group(1)`.select { |${1:item}| $2 }
endsnippet
@@ -197,7 +197,7 @@ endsnippet
snippet "(\S+)\.Sort" ".sort { |<a>,<b>| <block> }" r
-`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3:# TODO} }
+`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| $3 }
endsnippet
@@ -211,7 +211,7 @@ endsnippet
snippet "(\S+)\.Each_?k(ey)?" ".each_key { |<key>| <block> }" r
-`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2:# TODO} }
+`!p snip.rv=match.group(1)`.each_key { |${1:key}| $2 }
endsnippet
@@ -225,7 +225,7 @@ endsnippet
snippet "(\S+)\.Each_?val(ue)?" ".each_value { |<value>| <block> }" r
-`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2:# TODO} }
+`!p snip.rv=match.group(1)`.each_value { |${1:value}| $2 }
endsnippet
@@ -239,7 +239,7 @@ endsnippet
snippet Each "<elements>.each { |<element>| <block> }"
-${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} }
+${1:elements}.each { |${2:${1/s$//}}| $3 }
endsnippet
@@ -261,7 +261,7 @@ endsnippet
snippet Each_?s(lice)? "<array>.each_slice(n) { |slice| <block> }"
-each_slice(${1:2}) { |${2:slice}| ${3:# TODO} }
+each_slice(${1:2}) { |${2:slice}| $3 }
endsnippet
@@ -276,7 +276,7 @@ try:
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
-`}| ${2:# TODO} }
+`}| $2 }
endsnippet
@@ -306,7 +306,7 @@ try:
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
-`}| ${2:# TODO} }
+`}| $2 }
endsnippet
@@ -336,7 +336,7 @@ try:
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
-`}| ${2:# TODO} }
+`}| $2 }
endsnippet
@@ -367,7 +367,7 @@ try:
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
-`},${2:i}| ${3:# TODO} }$0
+`},${2:i}| $3 }$0
endsnippet
@@ -390,7 +390,7 @@ endsnippet
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} }
+`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| $3 }
endsnippet
@@ -403,32 +403,88 @@ endsnippet
-snippet "(\S+)\.sub" ".sub(<expression>) { <block> }" r
-`!p snip.rv=match.group(1)`.sub(${1:expression}) { ${2:"replace_with"} }
+snippet "(\S+)\.Each_?byte" ".each_byte { |<b>| <block> }" r
+`!p snip.rv=match.group(1)`.each_byte { |${1:b}| $2 }
+endsnippet
+
+
+
+snippet "(\S+)\.each_?byte" ".each_byte do |<b>| <block> end" r
+`!p snip.rv=match.group(1)`.each_byte do |${1:b}|
+ ${0:# TODO}
+end
+endsnippet
+
+
+
+snippet "(\S+)\.Each_?char" ".each_char { |<c>| <block> }" r
+`!p snip.rv=match.group(1)`.each_char { |${1:c}| $2 }
+endsnippet
+
+
+
+snippet "(\S+)\.each_?char" ".each_char do |<c>| <block> end" r
+`!p snip.rv=match.group(1)`.each_char do |${1:c}|
+ ${0:# TODO}
+end
+endsnippet
+
+
+
+snippet "(\S+)\.Each_?codepoint" ".each_codepoint { |<c>| <block> }" r
+`!p snip.rv=match.group(1)`.each_codepoint { |${1:c}| $2 }
endsnippet
-snippet "(\S+)\.gsub" ".gsub(<expression>) { <block> }" r
-`!p snip.rv=match.group(1)`.gsub(${1:expression}) { ${2:"replace_with"} }
+snippet "(\S+)\.each_?codepoint" ".each_codepoint do |<c>| <block> end" r
+`!p snip.rv=match.group(1)`.each_codepoint do |${1:c}|
+ ${0:# TODO}
+end
endsnippet
-snippet "(\S+)\.index" ".index { |item| <block> }" r
-`!p snip.rv=match.group(1)`.index { |${1:item}| ${2:block} }
+snippet "(\S+\.sub!?)" ".sub(<expression>, <replacement>)" r
+`!p snip.rv=match.group(1)`(${1:expression}, ${2:replacement})
endsnippet
-snippet "(\S+)\.Index" ".index do |item| ... end" r
+snippet "(\S+\.gsub!?)" ".gsub(<expression>, <replacement>)" r
+`!p snip.rv=match.group(1)`(${1:expression}, ${2:replacement})
+endsnippet
+
+
+
+snippet "(\S+)\.Index" ".index { |item| <block> }" r
+`!p snip.rv=match.group(1)`.index { |${1:item}| $2 }
+endsnippet
+
+
+
+snippet "(\S+)\.index" ".index do |item| ... end" r
`!p snip.rv=match.group(1)`.index do |${1:item}|
${0:block}
end
endsnippet
+snippet "(\S+)\.Times" ".times { |i| <block> }" r
+`!p snip.rv=match.group(1)`.times { |${1:i}| $2 }
+endsnippet
+
+
+
+snippet "(\S+)\.times" ".times do |item| ... end" r
+`!p snip.rv=match.group(1)`.times do |${1:i}|
+ ${0:block}
+end
+endsnippet
+
+
+
snippet do "do |<key>| ... end" i
do ${1:|${2:key}|}
$0

0 comments on commit 876125a

Please sign in to comment.