Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • rdoc/template.rb

Parent

Files

Class/Module Index [+]

Quicksearch

TemplatePage::LineReader

Simple class to read lines out of a string

Public Class Methods

new(lines) click to toggle source

we’re initialized with an array of lines

 
               # File rdoc/template.rb, line 87
def initialize(lines)
  @lines = lines
end
            

Public Instance Methods

dup() click to toggle source

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

 
               # File rdoc/template.rb, line 112
def dup
  LineReader.new(@lines.dup)
end
            
read() click to toggle source

read the next line

 
               # File rdoc/template.rb, line 92
def read
  @lines.shift
end
            
read_up_to(pattern) click to toggle source

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

 
               # 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
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus