Class SM::Lines
In: markup/simple_markup/lines.rb
Parent: Object

A container for all the lines

Methods

as_text   delete   each   empty?   line_types   new   next   normalize   rewind   unget  

Included Modules

Enumerable

Attributes

lines  [R] 

Public Class methods

[Source]

     # File markup/simple_markup/lines.rb, line 98
 98:     def initialize(lines)
 99:       @lines = lines
100:       rewind
101:     end

Public Instance methods

[Source]

     # File markup/simple_markup/lines.rb, line 143
143:     def as_text
144:       @lines.map {|l| l.text}.join("\n")
145:     end

[Source]

     # File markup/simple_markup/lines.rb, line 133
133:     def delete(a_line)
134:       a_line.deleted = true
135:     end

[Source]

     # File markup/simple_markup/lines.rb, line 107
107:     def each
108:       @lines.each do |line|
109:         yield line unless line.deleted
110:       end
111:     end

[Source]

     # File markup/simple_markup/lines.rb, line 103
103:     def empty?
104:       @lines.size.zero?
105:     end

[Source]

     # File markup/simple_markup/lines.rb, line 147
147:     def line_types
148:       @lines.map {|l| l.type }
149:     end

[Source]

     # File markup/simple_markup/lines.rb, line 121
121:     def next
122:       begin
123:         res = @lines[@nextline]
124:         @nextline += 1 if @nextline < @lines.size
125:       end while res and res.deleted and @nextline < @lines.size
126:       res
127:     end

[Source]

     # File markup/simple_markup/lines.rb, line 137
137:     def normalize
138:       margin = @lines.collect{|l| l.leading_spaces}.min
139:       margin = 0 if margin == Line::INFINITY
140:       @lines.each {|line| line.strip_leading(margin) } if margin > 0
141:     end

def [](index)

  @lines[index]

end

[Source]

     # File markup/simple_markup/lines.rb, line 117
117:     def rewind
118:       @nextline = 0
119:     end

[Source]

     # File markup/simple_markup/lines.rb, line 129
129:     def unget
130:       @nextline -= 1
131:     end

[Validate]