Class TemplatePage::LineReader
In: rdoc/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 rdoc/template.rb, line 87
    def initialize(lines)
      @lines = lines
    end

Public Instance methods

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

[Source]

# File rdoc/template.rb, line 112
    def dup
      LineReader.new(@lines.dup)
    end

read the next line

[Source]

# File rdoc/template.rb, line 92
    def read
      @lines.shift
    end

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

[Source]

# File rdoc/template.rb, line 98
    def read_up_to(pattern)
      res = []
      while line = read
        if pattern.match(line)
          return LineReader.new(res) 
        else
          res << line
        end
      end
      raise "Missing end tag in template: #{pattern.source}"
    end

[Validate]