Class: SM::Lines
- Inherits:
-
Object
- Object
- SM::Lines
- Includes:
- Enumerable
- Defined in:
- lib/rdoc/markup/simple_markup/lines.rb
Overview
#############################################################################
A container for all the lines
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
for debugging.
Instance Method Summary collapse
- #as_text ⇒ Object
- #delete(a_line) ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(lines) ⇒ Lines
constructor
A new instance of Lines.
- #line_types ⇒ Object
- #next ⇒ Object
- #normalize ⇒ Object
-
#rewind ⇒ Object
def [](index) @lines end.
- #unget ⇒ Object
Constructor Details
#initialize(lines) ⇒ Lines
Returns a new instance of Lines.
98 99 100 101 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 98 def initialize(lines) @lines = lines rewind end |
Instance Attribute Details
#lines ⇒ Object (readonly)
for debugging
96 97 98 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 96 def lines @lines end |
Instance Method Details
#as_text ⇒ Object
143 144 145 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 143 def as_text @lines.map {|l| l.text}.join("\n") end |
#delete(a_line) ⇒ Object
133 134 135 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 133 def delete(a_line) a_line.deleted = true end |
#each ⇒ Object
107 108 109 110 111 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 107 def each @lines.each do |line| yield line unless line.deleted end end |
#empty? ⇒ Boolean
103 104 105 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 103 def empty? @lines.size.zero? end |
#line_types ⇒ Object
147 148 149 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 147 def line_types @lines.map {|l| l.type } end |
#next ⇒ Object
121 122 123 124 125 126 127 |
# File 'lib/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 ⇒ Object
137 138 139 140 141 |
# File 'lib/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 ⇒ Object
def [](index)
@lines[index]
end
117 118 119 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 117 def rewind @nextline = 0 end |
#unget ⇒ Object
129 130 131 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 129 def unget @nextline -= 1 end |