####rb-enc
# encoding: utf-8
####rb-frozen
# frozen_string_literal: true
####rb-#!
#!/usr/bin/env ruby
####rb-=b
=begin rdoc
${0}
=end
####rb-prot
protected
${0}
####rb-priv
private
${0}
####rb-y
:yields: ${0:arguments}
####rb-rb
#!/usr/bin/env ruby -wKU
####rb-beg
begin
${0}
rescue ${1:Exception} => ${2:e}
end
####rb-req
require '${1}'
####rb-reqr
require_relative '${1}'
####rb-#
# =>
####rb-case
case ${1:object}
when ${2:condition}
${0}
end
####rb-when
when ${1:condition}
${0}
####rb-def
def ${1:method_name}
${0}
end
####rb-deft
def test_${1:case_name}
${0}
end
####rb-descendants
class Class
def descendants
ObjectSpace.each_object(::Class).select { |klass| klass < self }
end
end
####rb-if
if ${1:condition}
${0}
end
####rb-ife
if ${1:condition}
${2}
else
${0}
end
####rb-eif
elsif ${1:condition}
${0}
####rb-ifee
if ${1:condition}
$2
elsif ${3:condition}
$4
else
$0
end
####rb-unless
unless ${1:condition}
${0}
end
####rb-unlesse
unless ${1:condition}
$2
else
$0
end
####rb-unlesee
unless ${1:condition}
$2
elsif ${3:condition}
$4
else
$0
end
####rb-wh
while ${1:condition}
${0}
end
####rb-for
for ${1:e} in ${2:c}
${0}
end
####rb-until
until ${1:condition}
${0}
end
####rb-blankslate
class ${0:BlankSlate}
instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
end
####rb-claself
class << ${1:self}
${0}
end
####rb-r
attr_reader :${0:attr_names}
####rb-w
attr_writer :${0:attr_names}
####rb-rw
attr_accessor :${0:attr_names}
####rb-atp
attr_protected :${0:attr_names}
####rb-ata
attr_accessible :${0:attr_names}
####rb-ana
accepts_nested_attributes_for :${0:association}
####rb-ivc
@${1:variable_name} ||= ${0:cached_value}
####rb-Enum
include Enumerable
def each(&block)
${0}
end
####rb-Comp
include Comparable
def <=>(other)
${0}
end
####rb-Forw-
extend Forwardable
####rb-defs
def self.${1:class_method_name}
${0}
end
####rb-definit
def initialize(${1:args})
${0}
end
####rb-defmm
def method_missing(meth, *args, &blk)
${0}
end
####rb-defd
def_delegator :${1:@del_obj}, :${2:del_meth}, :${0:new_name}
####rb-defds
def_delegators :${1:@del_obj}, :${0:del_methods}
####rb-am
alias_method :${1:new_name}, :${0:old_name}
####rb-app
if __FILE__ == $PROGRAM_NAME
${0}
end
####rb-usai
if ARGV.${1}
abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${0}
end
####rb-usau
unless ARGV.${1}
abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${0}
end
####rb-array
Array.new(${1:10}) { |${2:i}| ${0} }
####rb-hash
Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${0} }
####rb-file
File.foreach(${1:'path/to/file'}) { |${2:line}| ${0} }
####rb-file
File.read(${1:'path/to/file'})
####rb-Dir
Dir.glob(${1:'dir/glob/*'}) { |${2:file}| ${0} }
####rb-Dir
Dir[${1:'glob/**/*.rb'}]
####rb-dir
Filename.dirname(__FILE__)
####rb-deli
delete_if { |${1:e}| ${0} }
####rb-fil
fill(${1:range}) { |${2:i}| ${0} }
####rb-flao
reduce(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2) }
####rb-zip
zip(${1:enums}) { |${2:row}| ${0} }
####rb-dow
downto(${1:0}) { |${2:n}| ${0} }
####rb-ste
step(${1:2}) { |${2:n}| ${0} }
####rb-tim
times { |${1:n}| ${0} }
####rb-upt
upto(${1:1.0/0.0}) { |${2:n}| ${0} }
####rb-loo
loop { ${0} }
####rb-ea
each { |${1:e}| ${0} }
####rb-ead
each do |${1:e}|
${0}
end
####rb-eab
each_byte { |${1:byte}| ${0} }
####rb-eac-
each_char { |${1:chr}| ${0} }
####rb-eac-
each_cons(${1:2}) { |${2:group}| ${0} }
####rb-eai
each_index { |${1:i}| ${0} }
####rb-eaid
each_index do |${1:i}|
${0}
end
####rb-eak
each_key { |${1:key}| ${0} }
####rb-eakd
each_key do |${1:key}|
${0}
end
####rb-eal
each_line { |${1:line}| ${0} }
####rb-eald
each_line do |${1:line}|
${0}
end
####rb-eap
each_pair { |${1:name}, ${2:val}| ${0} }
####rb-eapd
each_pair do |${1:name}, ${2:val}|
${0}
end
####rb-eas-
each_slice(${1:2}) { |${2:group}| ${0} }
####rb-easd-
each_slice(${1:2}) do |${2:group}|
${0}
end
####rb-eav
each_value { |${1:val}| ${0} }
####rb-eavd
each_value do |${1:val}|
${0}
end
####rb-eawi
each_with_index { |${1:e}, ${2:i}| ${0} }
####rb-eawid
each_with_index do |${1:e}, ${2:i}|
${0}
end
####rb-eawo
each_with_object(${1:init}) { |${2:e}, ${3:var}| ${0} }
####rb-eawod
each_with_object(${1:init}) do |${2:e}, ${3:var}|
${0}
end
####rb-reve
reverse_each { |${1:e}| ${0} }
####rb-reved
reverse_each do |${1:e}|
${0}
end
####rb-inj
inject(${1:init}) { |${2:mem}, ${3:var}| ${0} }
####rb-injd
inject(${1:init}) do |${2:mem}, ${3:var}|
${0}
end
####rb-red
reduce(${1:init}) { |${2:mem}, ${3:var}| ${0} }
####rb-redd
reduce(${1:init}) do |${2:mem}, ${3:var}|
${0}
end
####rb-map
map { |${1:e}| ${0} }
####rb-mapd
map do |${1:e}|
${0}
end
####rb-mapwi-
enum_with_index.map { |${1:e}, ${2:i}| ${0} }
####rb-sor
sort { |a, b| ${0} }
####rb-sorb
sort_by { |${1:e}| ${0} }
####rb-ran
sort_by { rand }
####rb-all
all? { |${1:e}| ${0} }
####rb-any
any? { |${1:e}| ${0} }
####rb-cl
classify { |${1:e}| ${0} }
####rb-col
collect { |${1:e}| ${0} }
####rb-cold
collect do |${1:e}|
${0}
end
####rb-det
detect { |${1:e}| ${0} }
####rb-detd
detect do |${1:e}|
${0}
end
####rb-fet
fetch(${1:name}) { |${2:key}| ${0} }
####rb-fin
find { |${1:e}| ${0} }
####rb-find
find do |${1:e}|
${0}
end
####rb-fina
find_all { |${1:e}| ${0} }
####rb-finad
find_all do |${1:e}|
${0}
end
####rb-gre
grep(${1:/pattern/}) { |${2:match}| ${0} }
####rb-sub
${1:g}sub(${2:/pattern/}) { |${3:match}| ${0} }
####rb-sca
scan(${1:/pattern/}) { |${2:match}| ${0} }
####rb-scad
scan(${1:/pattern/}) do |${2:match}|
${0}
end
####rb-max
max { |a, b| ${0} }
####rb-min
min { |a, b| ${0} }
####rb-par
partition { |${1:e}| ${0} }
####rb-pard
partition do |${1:e}|
${0}
end
####rb-rej
reject { |${1:e}| ${0} }
####rb-rejd
reject do |${1:e}|
${0}
end
####rb-sel
select { |${1:e}| ${0} }
####rb-seld
select do |${1:e}|
${0}
end
####rb-lam
lambda { |${1:args}| ${0} }
####rb-->
-> { ${0} }
####rb-->a
->(${1:args}) { ${0} }
####rb-do
do
${0}
end
####rb-dov
do |${1:v}|
${2}
end
####rb-:
${1:key}: ${2:'value'}
####rb-ope
open('${1:path/or/url/or/pipe}', '${2:w}') { |${3:io}| ${0} }
####rb-fpath
File.join(File.dirname(__FILE__), *['${1:rel path here}'])
####rb-unif
ARGF.each_line${1} do |${2:line}|
${0}
end
####rb-optp
require 'optparse'
options = { ${0:default: 'args'} }
ARGV.options do |opts|
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}"
end
####rb-opt
opts.on('-${1:o}', '--${2:long-option-name}', ${3:String}, '${4:Option description.}') do |${5:opt}|
${0}
end
####rb-tc
require 'test/unit'
require '${1:library_file_name}'
class Test${2:$1} < Test::Unit::TestCase
def test_${3:case_name}
${0}
end
end
####rb-ts
require 'test/unit'
require 'tc_${1:test_case_file}'
require 'tc_${2:test_case_file}'
####rb-as
assert ${1:test}, '${2:Failure message.}'
####rb-ase
assert_equal ${1:expected}, ${2:actual}
####rb-asne
assert_not_equal ${1:unexpected}, ${2:actual}
####rb-asid
assert_in_delta ${1:expected_float}, ${2:actual_float}, ${3:2**-20}
####rb-asi
assert_includes ${1:collection}, ${2:object}
####rb-asio
assert_instance_of ${1:ExpectedClass}, ${2:actual_instance}
####rb-asko
assert_kind_of ${1:ExpectedKind}, ${2:actual_instance}
####rb-asn
assert_nil ${1:instance}
####rb-asnn
assert_not_nil ${1:instance}
####rb-asm
assert_match(/${1:expected_pattern}/, ${2:actual_string})
####rb-asnm
assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})
####rb-aso
assert_operator ${1:left}, :${2:operator}, ${3:right}
####rb-asr
assert_raise ${1:Exception} { ${0} }
####rb-asrd
assert_raise ${1:Exception} do
${0}
end
####rb-asnr
assert_nothing_raised ${1:Exception} { ${0} }
####rb-asnrd
assert_nothing_raised ${1:Exception} do
${0}
end
####rb-asrt
assert_respond_to ${1:object}, :${2:method}
####rb-ass
assert_same ${1:expected}, ${2:actual}
####rb-ass
assert_send [${1:object}, :${2:message}, ${3:args}]
####rb-asns
assert_not_same ${1:unexpected}, ${2:actual}
####rb-ast
assert_throws :${1:expected}, -> { ${0} }
####rb-astd
assert_throws :${1:expected} do
${0}
end
####rb-asnt
assert_nothing_thrown { ${0} }
####rb-asntd
assert_nothing_thrown do
${0}
end
####rb-fl
flunk '${1:Failure message.}'
####rb-bm-
TESTS = ${1:10_000}
Benchmark.bmbm do |results|
${0}
end
####rb-rep
results.report('${1:name}:') { TESTS.times { ${0} } }
####rb-Md
File.open('${1:path/to/file.dump}', 'wb') { |${2:file}| Marshal.dump(${3:obj}, $2) }
####rb-Ml
File.open('${1:path/to/file.dump}', 'rb') { |${2:file}| Marshal.load($2) }
####rb-deec
Marshal.load(Marshal.dump(${1:obj_to_copy}))
####rb-Pn-
PStore.new('${1:file_name.pstore}')
####rb-tra
transaction(${1:true}) { ${0} }
####rb-xml-
REXML::Document.new(File.read('${1:path/to/file}'))
####rb-xpa
elements.each('${1://Xpath}') do |${2:node}|
${0}
end
####rb-clafn
split('::').inject(Object) { |par, const| par.const_get(const) }
####rb-sinc
class << self; self end
####rb-tas
desc '${1:Task description}'
task ${2:task_name: [:dependent, :tasks]} do
${0}
end
####rb-b
{ |${1:var}| ${0} }
####rb-begin
begin
fail 'A test exception.'
rescue Exception => e
puts e.message
puts e.backtrace.inspect
else
# other exception
ensure
# always executed
end
####rb-debug
require 'byebug'; byebug
####rb-debug19
require 'debugger'; debugger
####rb-debug18
require 'ruby-debug'; debugger
####rb-pry
require 'pry'; binding.pry
####rb-strf
strftime('${1:%Y-%m-%d %H:%M:%S %z}')${0}
####rb-mb
must_be ${0}
####rb-wb
wont_be ${0}
####rb-mbe
must_be_empty
####rb-wbe
wont_be_empty
####rb-mbio
must_be_instance_of ${0:Class}
####rb-wbio
wont_be_instance_of ${0:Class}
####rb-mbko
must_be_kind_of ${0:Class}
####rb-wbko
wont_be_kind_of ${0:Class}
####rb-mbn
must_be_nil
####rb-wbn
wont_be_nil
####rb-mbsa
must_be_same_as ${0:other}
####rb-wbsa
wont_be_same_as ${0:other}
####rb-mbsi
-> { ${0} }.must_be_silent
####rb-mbwd
must_be_within_delta ${1:0.1}, ${2:0.1}
####rb-wbwd
wont_be_within_delta ${1:0.1}, ${2:0.1}
####rb-mbwe
must_be_within_epsilon ${1:0.1}, ${2:0.1}
####rb-wbwe
wont_be_within_epsilon ${1:0.1}, ${2:0.1}
####rb-me
must_equal ${0:other}
####rb-we
wont_equal ${0:other}
####rb-mi
must_include ${0:what}
####rb-wi
wont_include ${0:what}
####rb-mm
must_match /${0:regex}/
####rb-wm
wont_match /${0:regex}/
####rb-mout
-> { ${1} }.must_output '${0}'
####rb-mra
-> { ${1} }.must_raise ${0:Exception}
####rb-mrt
must_respond_to :${0:method}
####rb-wrt
wont_respond_to :${0:method}
####rb-msend
must_send [ ${1:what}, :${2:method}, ${3:args} ]
####rb-mthrow
-> { throw :${1:error} }.must_throw :${2:error}
####rb-descm
describe '${1:#method}' do
${0:pending 'Not implemented'}
end
####rb-cont
context '${1:message}' do
${0}
end
####rb-bef
before :${1:each} do
${0}
end
####rb-aft
after :${1:each} do
${0}
end
####rb-let
let(:${1:object}) { ${0} }
####rb-let!
let!(:${1:object}) { ${0} }
####rb-subj
subject { ${0} }
####rb-s.
subject.${0:method}
####rb-spec
specify { subject.${0} }
####rb-exp
expect(${1:object}).to ${0}
####rb-expb
expect { ${1:object} }.to ${0}
####rb-experr
expect { ${1:object} }.to raise_error ${2:StandardError}, /${0:message_regex}/
####rb-shared
shared_examples ${0:'shared examples name'}
####rb-ibl
it_behaves_like ${0:'shared examples name'}
####rb-it
it '${1:spec_name}' do
${0}
end
####rb-its
its(:${1:method}) { should ${0} }
####rb-is
it { should ${0} }
####rb-isn
it { should_not ${0} }
####rb-iexp
it { expect(${1:object}).${1} ${0} }
####rb-iexpb
it { expect { ${1:object} }.${1} ${0} }
####rb-iiexp
it { is_expected.to ${0} }
####rb-iiexpn
it { is_expected.not_to ${0} }