Class: Eceval::Chunk

Inherits:
Object
  • Object
show all
Defined in:
lib/eceval.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename:, lineno:) ⇒ Chunk

Returns a new instance of Chunk.



142
143
144
145
146
# File 'lib/eceval.rb', line 142

def initialize(filename:, lineno:)
  @filename = filename
  @lineno = lineno
  @buffered_lines = []
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



140
141
142
# File 'lib/eceval.rb', line 140

def filename
  @filename
end

#linenoObject (readonly)

Returns the value of attribute lineno.



140
141
142
# File 'lib/eceval.rb', line 140

def lineno
  @lineno
end

Instance Method Details

#<<(line) ⇒ Object



148
149
150
# File 'lib/eceval.rb', line 148

def <<(line)
  @buffered_lines << line
end

#evaluateObject



152
153
154
# File 'lib/eceval.rb', line 152

def evaluate
  ECEVAL_MAIN_BINDING.eval(@buffered_lines.join("\n"), filename, lineno)
end