Class: Ragel::Array::Replace::Buffer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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



39
40
41
# File 'lib/ragel/array/replace.rb', line 39

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