Class: Landescape::Evaluator::Base
- Inherits:
-
Object
- Object
- Landescape::Evaluator::Base
- Defined in:
- lib/landescape/evaluator.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#statements ⇒ Object
readonly
Returns the value of attribute statements.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(statements, window, options = {}) ⇒ Base
constructor
A new instance of Base.
- #not_supported(name, *args) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #unknown(token) ⇒ Object
Constructor Details
#initialize(statements, window, options = {}) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 |
# File 'lib/landescape/evaluator.rb', line 12 def initialize(statements, window, = {}) @options = {non_block: false}.merge() @window = window @statements = statements end |
Instance Attribute Details
#statements ⇒ Object (readonly)
Returns the value of attribute statements.
10 11 12 |
# File 'lib/landescape/evaluator.rb', line 10 def statements @statements end |
Class Method Details
.start(statements, window, options = {}) ⇒ Object
5 6 7 |
# File 'lib/landescape/evaluator.rb', line 5 def start(statements, window, = {}) new(statements, window, ).tap(&:start) end |
Instance Method Details
#not_supported(name, *args) ⇒ Object
45 46 47 |
# File 'lib/landescape/evaluator.rb', line 45 def not_supported(name, *args) Landescape.logger.warn %([not supported] #{name}(#{args.join(', ')})) end |
#start ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/landescape/evaluator.rb', line 18 def start @eval_thread = Thread.fork { loop do name, *args = begin statements.shift(@options[:non_block]) rescue ThreadError Thread.exit end if self.class.method_defined?(name) __send__ name, *args else not_supported name, *args end end } end |
#stop ⇒ Object
37 38 39 |
# File 'lib/landescape/evaluator.rb', line 37 def stop @eval_thread.exit if @eval_thread.alive? end |
#unknown(token) ⇒ Object
41 42 43 |
# File 'lib/landescape/evaluator.rb', line 41 def unknown(token) Landescape.logger.warn %([unknown] #{token.inspect}) end |