Class: Fir::Evaluater
- Inherits:
-
Object
- Object
- Fir::Evaluater
- Includes:
- ScreenHelper
- Defined in:
- lib/fir/evaluater.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(output, error) ⇒ Evaluater
constructor
A new instance of Evaluater.
- #perform(state) ⇒ Object
Methods included from ScreenHelper
#clear, #cursor_back, #horizontal_absolute, #line_prompt, #next_line, #previous_line
Constructor Details
#initialize(output, error) ⇒ Evaluater
Returns a new instance of Evaluater.
13 14 15 16 |
# File 'lib/fir/evaluater.rb', line 13 def initialize(output, error) @output = output @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
11 12 13 |
# File 'lib/fir/evaluater.rb', line 11 def error @error end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
10 11 12 |
# File 'lib/fir/evaluater.rb', line 10 def output @output end |
Instance Method Details
#perform(state) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fir/evaluater.rb', line 18 def perform(state) return unless state.executable? begin write_result(eval(state.lines.join("\n"), state.repl_binding, 'fir')) rescue Exception => e write_error(e) ensure output.syswrite(line_prompt) end end |