Class TemplatePage::LineReader
In: template.rb
Parent: Object

Simple class to read lines out of a string

Methods

dup   new   read   read_up_to  

Public Class methods

we‘re initialized with an array of lines

[Source]

    # File template.rb, line 87
87:     def initialize(lines)
88:       @lines = lines
89:     end

Public Instance methods

Return a copy of ourselves that can be modified without affecting us

[Source]

     # File template.rb, line 112
112:     def dup
113:       LineReader.new(@lines.dup)
114:     end

read the next line

[Source]

    # File template.rb, line 92
92:     def read
93:       @lines.shift
94:     end

Return a list of lines up to the line that matches a pattern. That last line is discarded.

[Source]

     # 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

[Validate]