Class: Rapel::Expression
- Inherits:
-
Object
- Object
- Rapel::Expression
- Defined in:
- lib/rapel/expression.rb
Instance Method Summary collapse
- #evaluate(context) {|result| ... } ⇒ Object
-
#initialize(exp) ⇒ Expression
constructor
A new instance of Expression.
- #inspect ⇒ Object
Constructor Details
#initialize(exp) ⇒ Expression
Returns a new instance of Expression.
4 5 6 |
# File 'lib/rapel/expression.rb', line 4 def initialize(exp) @expression = exp end |
Instance Method Details
#evaluate(context) {|result| ... } ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rapel/expression.rb', line 8 def evaluate(context) $stdout.puts("Evaluating #{self.inspect} within #{context.inspect}") result = {session_id: context.session_id} begin context.socket.puts(Rapel.escape_newlines(@expression)) value = context.socket.gets.chomp result[:result] = Rapel.unescape_newlines(value) rescue Exception => e $stdout.puts e result[:result] = "" result[:error] = e. end $stdout.puts "Received #{value.inspect} from #{context.inspect}" yield result end |
#inspect ⇒ Object
25 26 27 |
# File 'lib/rapel/expression.rb', line 25 def inspect @expression.inspect end |