Class: Ragel::Bitmap::Replace::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/ragel/bitmap/replace.rb

Overview

Represents the source as it changes

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#linesObject (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_sourceObject



118
119
120
# File 'lib/ragel/bitmap/replace.rb', line 118

def to_source
  "#{lines.join("\n")}\n"
end