| Class | TemplatePage::LineReader |
| In: |
template.rb
|
| Parent: | Object |
Simple class to read lines out of a string
we‘re initialized with an array of lines
# File template.rb, line 87
87: def initialize(lines)
88: @lines = lines
89: end
Return a copy of ourselves that can be modified without affecting us
# File template.rb, line 112
112: def dup
113: LineReader.new(@lines.dup)
114: end
Return a list of lines up to the line that matches a pattern. That last line is discarded.
# File template.rb, line 98
98: def read_up_to(pattern)
99: res = []
100: while line = read
101: if pattern.match(line)
102: return LineReader.new(res)
103: else
104: res << line
105: end
106: end
107: raise "Missing end tag in template: #{pattern.source}"
108: end