首页 > 编程语言 >ruby snippets

ruby snippets

时间:2023-01-09 13:24:08浏览次数:46  
标签:do end .. assert snippet each ruby snippets

snippet enc
# encoding: utf-8
snippet frozen
# frozen_string_literal: true
snippet #!
#!/usr/bin/env ruby

New Block

snippet =b
=begin rdoc
${0}
=end
snippet prot
protected

${0}

snippet priv
private

${0}

snippet y
:yields: ${0:arguments}
snippet rb
#!/usr/bin/env ruby -wKU
snippet beg
begin
${0}
rescue ${1:StandardError} => ${2:e}
end
snippet req require
require '${1}'
snippet reqr
require_relative '${1}'
snippet #
# =>
snippet case
case ${1:object}
when ${2:condition}
${0}
end
snippet when
when ${1:condition}
${0:${VISUAL}}
snippet def
def ${1:method_name}
${0}
end
snippet deft
def test_${1:case_name}
${0}
end
snippet descendants
class Class
def descendants
ObjectSpace.each_object(::Class).select { |klass| klass < self }
end
end
snippet if
if ${1:condition}
${0:${VISUAL}}
end
snippet ife
if ${1:condition}
${2:${VISUAL}}
else
${0}
end
snippet eif
elsif ${1:condition}
${0:${VISUAL}}
snippet ifee
if ${1:condition}
$2
elsif ${3:condition}
$4
else
$0
end
snippet unless
unless ${1:condition}
${0:${VISUAL}}
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
while ${1:condition}
${0:${VISUAL}}
end
snippet for
for ${1:e} in ${2:c}
${0}
end
snippet until
until ${1:condition}
${0:${VISUAL}}
end
snippet cla class .. end
class ${1:substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')}
${0}
end
snippet clai class .. initialize .. end
class ${1:substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')}
def initialize(${2:args})
${0}
end
end
snippet cla< class .. < ParentClass .. initialize .. end
class ${1:substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')} < ${2:ParentClass}
def initialize(${3:args})
${0}
end
end
snippet blankslate class BlankSlate .. initialize .. end
class ${0:BlankSlate}
instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
end
snippet claself class << self .. end
class << ${1:self}
${0}
end

class .. < DelegateClass .. initialize .. end

snippet cla-
class ${1:substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')} < DelegateClass(${2:ParentClass})
def initialize(${3:args})
super(${4:del_obj})

		${0}
	end
end

snippet mod module .. end
module ${1:substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')}
${0}
end

attr_reader

snippet r
attr_reader

标签:do,end,..,assert,snippet,each,ruby,snippets
From: https://www.cnblogs.com/cloudhan/p/17036734.html

相关文章