11 :yields: ${1:arguments}
13 #!/usr/bin/env ruby -wKU
17 rescue ${1:Exception} => ${2:e}
39 def test_${1:case_name}
71 snippet cla class .. end
72 class ${1:`substitute(Filename(), '^.', '\u&', '')`}
75 snippet cla class .. initialize .. end
76 class ${1:`substitute(Filename(), '^.', '\u&', '')`}
77 def initialize(${2:args})
83 snippet cla class .. < ParentClass .. initialize .. end
84 class ${1:`substitute(Filename(), '^.', '\u&', '')`} < ${2:ParentClass}
85 def initialize(${3:args})
91 snippet cla ClassName = Struct .. do .. end
92 ${1:`substitute(Filename(), '^.', '\u&', '')`} = Struct.new(:${2:attr_names}) do
99 snippet cla class BlankSlate .. initialize .. end
100 class ${1:BlankSlate}
101 instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
102 snippet cla class << self .. end
106 # class .. < DelegateClass .. initialize .. end
108 class ${1:`substitute(Filename(), '^.', '\u&', '')`} < DelegateClass(${2:ParentClass})
109 def initialize(${3:args})
117 snippet mod module .. end
118 module ${1:`substitute(Filename(), '^.', '\u&', '')`}
121 snippet mod module .. module_function .. end
122 module ${1:`substitute(Filename(), '^.', '\u&', '')`}
127 snippet mod module .. ClassMethods .. end
128 module ${1:`substitute(Filename(), '^.', '\u&', '')`}
133 module InstanceMethods
137 def self.included(receiver)
138 receiver.extend ClassMethods
139 receiver.send :include, InstanceMethods
144 attr_reader :${1:attr_names}
147 attr_writer :${1:attr_names}
150 attr_accessor :${1:attr_names}
170 def self.${1:class_method_name}
175 def method_missing(meth, *args, &blk)
179 def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name}
181 def_delegators :${1:@del_obj}, :${2:del_methods}
183 alias_method :${1:new_name}, :${2:old_name}
185 if __FILE__ == $PROGRAM_NAME
191 abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3}
196 abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3}
199 Array.new(${1:10}) { |${2:i}| ${3} }
201 Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} }
202 snippet file File.foreach() { |line| .. }
203 File.foreach(${1:"path/to/file"}) { |${2:line}| ${3} }
204 snippet file File.read()
205 File.read(${1:"path/to/file"})${2}
206 snippet Dir Dir.global() { |file| .. }
207 Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${3} }
208 snippet Dir Dir[".."]
209 Dir[${1:"glob/**/*.rb"}]${2}
211 Filename.dirname(__FILE__)
213 delete_if { |${1:e}| ${2} }
215 fill(${1:range}) { |${2:i}| ${3} }
218 inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3}
220 zip(${1:enums}) { |${2:row}| ${3} }
221 # downto(0) { |n| .. }
223 downto(${1:0}) { |${2:n}| ${3} }
225 step(${1:2}) { |${2:n}| ${3} }
227 times { |${1:n}| ${2} }
229 upto(${1:1.0/0.0}) { |${2:n}| ${3} }
233 each { |${1:e}| ${2} }
239 each_byte { |${1:byte}| ${2} }
240 snippet eac- each_char { |chr| .. }
241 each_char { |${1:chr}| ${2} }
242 snippet eac- each_cons(..) { |group| .. }
243 each_cons(${1:2}) { |${2:group}| ${3} }
245 each_index { |${1:i}| ${2} }
247 each_index do |${1:i}|
250 each_key { |${1:key}| ${2} }
252 each_key do |${1:key}|
256 each_line { |${1:line}| ${2} }
258 each_line do |${1:line}|
262 each_pair { |${1:name}, ${2:val}| ${3} }
264 each_pair do |${1:name}, ${2:val}|
268 each_slice(${1:2}) { |${2:group}| ${3} }
270 each_slice(${1:2}) do |${2:group}|
274 each_value { |${1:val}| ${2} }
276 each_value do |${1:val}|
280 each_with_index { |${1:e}, ${2:i}| ${3} }
282 each_with_index do |${1:e},${2:i}|
286 reverse_each { |${1:e}| ${2} }
288 reverse_each do |${1:e}|
292 inject(${1:init}) { |${2:mem}, ${3:var}| ${4} }
294 inject(${1:init}) do |${2:mem}, ${3:var}|
298 map { |${1:e}| ${2} }
304 enum_with_index.map { |${1:e}, ${2:i}| ${3} }
308 sort_by { |${1:e}| ${2} }
312 all? { |${1:e}| ${2} }
314 any? { |${1:e}| ${2} }
316 classify { |${1:e}| ${2} }
318 collect { |${1:e}| ${2} }
324 detect { |${1:e}| ${2} }
330 fetch(${1:name}) { |${2:key}| ${3} }
332 find { |${1:e}| ${2} }
338 find_all { |${1:e}| ${2} }
344 grep(${1:/pattern/}) { |${2:match}| ${3} }
346 ${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} }
348 scan(${1:/pattern/}) { |${2:match}| ${3} }
350 scan(${1:/pattern/}) do |${2:match}|
358 partition { |${1:e}| ${2} }
360 partition do |${1:e}|
364 reject { |${1:e}| ${2} }
370 select { |${1:e}| ${2} }
376 lambda { |${1:args}| ${2} }
382 :${1:key} => ${2:"value"}${3}
384 open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} }
387 File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2}
390 ARGF.each_line${1} do |${2:line}|
397 options = {${1:default => "args"}}
399 ARGV.options do |opts|
400 opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}
402 opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String},
403 "${4:Option description.}") do |${5:opt}|
409 require "${1:library_file_name}"
411 class Test${2:$1} < Test::Unit::TestCase
412 def test_${3:case_name}
419 require "tc_${1:test_case_file}"
420 require "tc_${2:test_case_file}"${3}
422 assert(${1:test}, "${2:Failure message.}")${3}
424 assert_equal(${1:expected}, ${2:actual})${3}
426 assert_not_equal(${1:unexpected}, ${2:actual})${3}
428 assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4}
430 assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3}
432 assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3}
434 assert_nil(${1:instance})${2}
436 assert_not_nil(${1:instance})${2}
438 assert_match(/${1:expected_pattern}/, ${2:actual_string})${3}
440 assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3}
442 assert_operator(${1:left}, :${2:operator}, ${3:right})${4}
444 assert_raise(${1:Exception}) { ${2} }
446 assert_nothing_raised(${1:Exception}) { ${2} }
448 assert_respond_to(${1:object}, :${2:method})${3}
449 snippet ass assert_same(..)
450 assert_same(${1:expected}, ${2:actual})${3}
451 snippet ass assert_send(..)
452 assert_send([${1:object}, :${2:message}, ${3:args}])${4}
454 assert_not_same(${1:unexpected}, ${2:actual})${3}
456 assert_throws(:${1:expected}) { ${2} }
458 assert_nothing_thrown { ${1} }
460 flunk("${1:Failure message.}")${2}
461 # Benchmark.bmbm do .. end
464 Benchmark.bmbm do |results|
468 results.report("${1:name}:") { TESTS.times { ${2} }}
469 # Marshal.dump(.., file)
471 File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4}
474 File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }${3}
477 Marshal.load(Marshal.dump(${1:obj_to_copy}))${2}
479 PStore.new(${1:"file_name.pstore"})${2}
481 transaction(${1:true}) { ${2} }
484 REXML::Document.new(File.read(${1:"path/to/file"}))${2}
487 elements.each(${1:"//Xpath"}) do |${2:node}|
492 split("::").inject(Object) { |par, const| par.const_get(const) }
495 class << self; self end
497 namespace :${1:`Filename()`} do
501 desc "${1:Task description\}"
502 task :${2:task_name => [:dependent, :tasks]} do