Ruby: Remove some duplication
This commit is contained in:
parent
2796cf66de
commit
b988fb9576
@ -10,54 +10,6 @@ snippet "^# ?[uU][tT][fF]-?8" "# encoding: UTF-8" r
|
|||||||
$0
|
$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet if "if <condition> ... end"
|
|
||||||
if ${1:condition}
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ife "if <condition> ... else ... end"
|
|
||||||
if ${1:condition}
|
|
||||||
$2
|
|
||||||
else
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet ifee "if <condition> ... elseif <condition> ... else ... end"
|
|
||||||
if ${1:condition}
|
|
||||||
$2
|
|
||||||
elsif ${3:condition}
|
|
||||||
$4
|
|
||||||
else
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet unless "unless <condition> ... end"
|
|
||||||
unless ${1:condition}
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet unlesse "unless <condition> ... else ... end"
|
|
||||||
unless ${1:condition}
|
|
||||||
$2
|
|
||||||
else
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet unlesee "unless <condition> ... elseif <condition> ... else ... end"
|
|
||||||
unless ${1:condition}
|
|
||||||
$2
|
|
||||||
elsif ${3:condition}
|
|
||||||
$4
|
|
||||||
else
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
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})}
|
||||||
$0
|
$0
|
||||||
@ -82,12 +34,6 @@ snippet For "(<from>..<to>).each { |<i>| <block> }"
|
|||||||
(${1:from}..${2:to}).each { |${3:i}| $0 }
|
(${1:from}..${2:to}).each { |${3:i}| $0 }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet for "(<from>..<to>).each do |<i>| <block> end"
|
|
||||||
(${1:from}..${2:to}).each do |${3:i}|
|
|
||||||
$0
|
|
||||||
end
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet "(\S+)\.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} }
|
`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) { |${2:key},${3:oldval},${4:newval}| ${5:block} }
|
||||||
endsnippet
|
endsnippet
|
||||||
@ -168,12 +114,12 @@ snippet "(\S+)\.each_?val(ue)?" ".each_value do |<value>| <block> end" r
|
|||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet Each "<elements>.each { |<element>| <block> }"
|
snippet "(\S+)\.ea" "<elements>.each do |<element>| <block> end" r
|
||||||
${1:elements}.each { |${2:${1/s$//}}| $0 }
|
`!p snip.rv=match.group(1)`.each { |${1:e}| $0 }
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet each "<elements>.each do |<element>| <block> end"
|
snippet "(\S+)\.ead" "<elements>.each do |<element>| <block> end" r
|
||||||
${1:elements}.each do |${2:${1/s$//}}|
|
`!p snip.rv=match.group(1)`.each do |${1:e}|
|
||||||
$0
|
$0
|
||||||
end
|
end
|
||||||
endsnippet
|
endsnippet
|
||||||
|
@ -73,10 +73,32 @@ snippet ife
|
|||||||
snippet eif
|
snippet eif
|
||||||
elsif ${1:condition}
|
elsif ${1:condition}
|
||||||
${0}
|
${0}
|
||||||
|
snippet ifee
|
||||||
|
if ${1:condition}
|
||||||
|
$2
|
||||||
|
elsif ${3:condition}
|
||||||
|
$4
|
||||||
|
else
|
||||||
|
$0
|
||||||
|
end
|
||||||
snippet unless
|
snippet unless
|
||||||
unless ${1:condition}
|
unless ${1:condition}
|
||||||
${0}
|
${0}
|
||||||
end
|
end
|
||||||
|
snippet unlesse
|
||||||
|
unless ${1:condition}
|
||||||
|
$2
|
||||||
|
else
|
||||||
|
$0
|
||||||
|
end
|
||||||
|
snippet unlesee
|
||||||
|
unless ${1:condition}
|
||||||
|
$2
|
||||||
|
elsif ${3:condition}
|
||||||
|
$4
|
||||||
|
else
|
||||||
|
$0
|
||||||
|
end
|
||||||
snippet wh
|
snippet wh
|
||||||
while ${1:condition}
|
while ${1:condition}
|
||||||
${0}
|
${0}
|
||||||
|
Loading…
Reference in New Issue
Block a user