Class: Ragel::Array::Replace::Buffer
- Inherits:
-
Object
- Object
- Ragel::Array::Replace::Buffer
- Defined in:
- lib/ragel/array/replace.rb
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
Instance Method Summary collapse
-
#initialize(source) ⇒ Buffer
constructor
A new instance of Buffer.
- #replace(table) ⇒ Object
- #to_source ⇒ Object
Constructor Details
#initialize(source) ⇒ Buffer
Returns a new instance of Buffer.
28 29 30 |
# File 'lib/ragel/array/replace.rb', line 28 def initialize(source) @lines = source.split("\n") end |
Instance Attribute Details
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
26 27 28 |
# File 'lib/ragel/array/replace.rb', line 26 def lines @lines end |
Instance Method Details
#replace(table) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/ragel/array/replace.rb', line 32 def replace(table) buffer = lines[table.start_line][/\A\s+/] source = ["#{buffer}#{table.source}"] @lines = lines[0...table.start_line] + source + lines[table.end_line..-1] end |
#to_source ⇒ Object
39 40 41 |
# File 'lib/ragel/array/replace.rb', line 39 def to_source "#{lines.join("\n")}\n" end |