class Yada::Input
Public Class Methods
new(source, stop = /\.\s+/)
click to toggle source
# File lib/yada/input.rb, line 5 def initialize(source, stop = /\.\s+/) @source, @stop = source, stop end
Public Instance Methods
each() { |accumulator| ... }
click to toggle source
# File lib/yada/input.rb, line 9 def each(&block) accumulator = '' @source.each do |line| accumulator = regroup(accumulator, line, &block) end yield accumulator if accumulator != '' nil end
Private Instance Methods
regroup(accumulator, text) { |accumulator| ... }
click to toggle source
# File lib/yada/input.rb, line 18 def regroup(accumulator, text, &block) pre, stop, rest = text.partition(@stop) return accumulator + pre if stop == '' yield accumulator + pre + stop regroup('', rest, &block) end