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

In Files

  • rdoc/markup/simple_markup/lines.rb

Parent

Included Modules

Files

Class/Module Index [+]

Quicksearch

SM::Lines

A container for all the lines

Attributes

lines[R]

Public Class Methods

new(lines) click to toggle source
 
               # File rdoc/markup/simple_markup/lines.rb, line 98
def initialize(lines)
  @lines = lines
  rewind
end
            

Public Instance Methods

as_text() click to toggle source
 
               # File rdoc/markup/simple_markup/lines.rb, line 143
def as_text
  @lines.map {|l| l.text}.join("\n")
end
            
delete(a_line) click to toggle source
 
               # File rdoc/markup/simple_markup/lines.rb, line 133
def delete(a_line)
  a_line.deleted = true
end
            
each() click to toggle source
 
               # File rdoc/markup/simple_markup/lines.rb, line 107
def each
  @lines.each do |line|
    yield line unless line.deleted
  end
end
            
empty?() click to toggle source
 
               # File rdoc/markup/simple_markup/lines.rb, line 103
def empty?
  @lines.size.zero?
end
            
line_types() click to toggle source
 
               # File rdoc/markup/simple_markup/lines.rb, line 147
def line_types
  @lines.map {|l| l.type }
end
            
next() click to toggle source
 
               # File rdoc/markup/simple_markup/lines.rb, line 121
def next
  begin
    res = @lines[@nextline]
    @nextline += 1 if @nextline < @lines.size
  end while res and res.deleted and @nextline < @lines.size
  res
end
            
normalize() click to toggle source
 
               # File rdoc/markup/simple_markup/lines.rb, line 137
def normalize
  margin = @lines.collect{|l| l.leading_spaces}.min
  margin = 0 if margin == Line::INFINITY
  @lines.each {|line| line.strip_leading(margin) } if margin > 0
end
            
rewind() click to toggle source

def [](index)

@lines[index]

end

 
               # File rdoc/markup/simple_markup/lines.rb, line 117
def rewind
  @nextline = 0
end
            
unget() click to toggle source
 
               # File rdoc/markup/simple_markup/lines.rb, line 129
def unget
  @nextline -= 1
end