Class: RDocF95::Markup::Lines
- Inherits:
-
Object
- Object
- RDocF95::Markup::Lines
- Includes:
- Enumerable
- Defined in:
- lib/rdoc-f95/markup/lines.rb
Overview
A container for all the lines.
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
:nodoc:.
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.
96 97 98 99 |
# File 'lib/rdoc-f95/markup/lines.rb', line 96 def initialize(lines) @lines = lines rewind end |
Instance Attribute Details
#lines ⇒ Object (readonly)
:nodoc:
94 95 96 |
# File 'lib/rdoc-f95/markup/lines.rb', line 94 def lines @lines end |
Instance Method Details
#as_text ⇒ Object
141 142 143 |
# File 'lib/rdoc-f95/markup/lines.rb', line 141 def as_text @lines.map {|l| l.text}.join("\n") end |
#delete(a_line) ⇒ Object
131 132 133 |
# File 'lib/rdoc-f95/markup/lines.rb', line 131 def delete(a_line) a_line.deleted = true end |
#each ⇒ Object
105 106 107 108 109 |
# File 'lib/rdoc-f95/markup/lines.rb', line 105 def each @lines.each do |line| yield line unless line.deleted end end |
#empty? ⇒ Boolean
101 102 103 |
# File 'lib/rdoc-f95/markup/lines.rb', line 101 def empty? @lines.size.zero? end |
#line_types ⇒ Object
145 146 147 |
# File 'lib/rdoc-f95/markup/lines.rb', line 145 def line_types @lines.map {|l| l.type } end |
#next ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/rdoc-f95/markup/lines.rb', line 119 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
135 136 137 138 139 |
# File 'lib/rdoc-f95/markup/lines.rb', line 135 def normalize margin = @lines.collect{|l| l.leading_spaces}.min margin = 0 if margin == :INFINITY @lines.each {|line| line.strip_leading(margin) } if margin > 0 end |
#rewind ⇒ Object
def [](index)
@lines[index]
end
115 116 117 |
# File 'lib/rdoc-f95/markup/lines.rb', line 115 def rewind @nextline = 0 end |
#unget ⇒ Object
127 128 129 |
# File 'lib/rdoc-f95/markup/lines.rb', line 127 def unget @nextline -= 1 end |