Module: Degem::Scan
- Defined in:
- lib/degem/parse_ruby.rb
Instance Method Summary collapse
Instance Method Details
#scan(init = nil) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/degem/parse_ruby.rb', line 102 def scan(init = nil) if init.nil? init = self[0] xs = self[1..] || [] else xs = self end return self if xs.empty? xs.reduce([init]) do |acc, x| acc + [yield(acc.last, x)] end end |