Class: Ruby::Node::Text::Clip
Instance Attribute Summary collapse
-
#col ⇒ Object
readonly
Returns the value of attribute col.
-
#end ⇒ Object
Returns the value of attribute end.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
Instance Method Summary collapse
- #head ⇒ Object
-
#initialize(lines, pos, length = nil) ⇒ Clip
constructor
A new instance of Clip.
- #src ⇒ Object
- #tail ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(lines, pos, length = nil) ⇒ Clip
Returns a new instance of Clip.
54 55 56 57 58 59 |
# File 'lib/ruby/node/text.rb', line 54 def initialize(lines, pos, length = nil) @lines = lines.is_a?(::String) ? Text.split(lines) : lines @row, @col = *pos @length = length.nil? ? self.lines.join.length : length init end |
Instance Attribute Details
#col ⇒ Object (readonly)
Returns the value of attribute col.
52 53 54 |
# File 'lib/ruby/node/text.rb', line 52 def col @col end |
#end ⇒ Object
Returns the value of attribute end.
52 53 54 |
# File 'lib/ruby/node/text.rb', line 52 def end @end end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
52 53 54 |
# File 'lib/ruby/node/text.rb', line 52 def length @length end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
52 53 54 |
# File 'lib/ruby/node/text.rb', line 52 def lines @lines end |
#row ⇒ Object (readonly)
Returns the value of attribute row.
52 53 54 |
# File 'lib/ruby/node/text.rb', line 52 def row @row end |
Instance Method Details
#head ⇒ Object
69 70 71 |
# File 'lib/ruby/node/text.rb', line 69 def head lines[0, row].join + lines[row][0, col] end |
#src ⇒ Object
77 78 79 |
# File 'lib/ruby/node/text.rb', line 77 def src lines.join end |
#tail ⇒ Object
73 74 75 |
# File 'lib/ruby/node/text.rb', line 73 def tail lines[self.end.row][self.end.col..-1] + lines[(self.end.row + 1)..-1].join end |
#to_s ⇒ Object
81 82 83 |
# File 'lib/ruby/node/text.rb', line 81 def to_s @string end |