Class: Ragel::Bitmap::Replace::Buffer
- Inherits:
-
Object
- Object
- Ragel::Bitmap::Replace::Buffer
- Defined in:
- lib/ragel/bitmap/replace.rb
Overview
Represents the source as it changes
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.
106 107 108 |
# File 'lib/ragel/bitmap/replace.rb', line 106 def initialize(source) @lines = source.split("\n") end |
Instance Attribute Details
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
104 105 106 |
# File 'lib/ragel/bitmap/replace.rb', line 104 def lines @lines end |
Instance Method Details
#replace(table) ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/ragel/bitmap/replace.rb', line 110 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
118 119 120 |
# File 'lib/ragel/bitmap/replace.rb', line 118 def to_source "#{lines.join("\n")}\n" end |