Class: Sevgi::Executor::Scope
- Inherits:
-
Object
- Object
- Sevgi::Executor::Scope
- Defined in:
- lib/sevgi/executor/scope.rb
Constant Summary collapse
- Error =
Class.new(::Sevgi::Error)
- MAIN_MODULE =
:Main
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#recent ⇒ Object
readonly
Returns the value of attribute recent.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #call(source, receiver = nil, &boot) ⇒ Object
- #error? ⇒ Boolean
-
#initialize(scope = nil) ⇒ Scope
constructor
A new instance of Scope.
- #load(file, &block) ⇒ Object
- #peek ⇒ Object
- #stack ⇒ Object
Constructor Details
#initialize(scope = nil) ⇒ Scope
Returns a new instance of Scope.
10 11 12 13 14 15 |
# File 'lib/sevgi/executor/scope.rb', line 10 def initialize(scope = nil) @scope = scope || main @recent = nil @error = nil @stack = {} end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
8 9 10 |
# File 'lib/sevgi/executor/scope.rb', line 8 def error @error end |
#recent ⇒ Object (readonly)
Returns the value of attribute recent.
8 9 10 |
# File 'lib/sevgi/executor/scope.rb', line 8 def recent @recent end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
8 9 10 |
# File 'lib/sevgi/executor/scope.rb', line 8 def scope @scope end |
Instance Method Details
#call(source, receiver = nil, &boot) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sevgi/executor/scope.rb', line 19 def call(source, receiver = nil, &boot) push(source) tap do @recent = begin boot(receiver, &boot) evaluate(source) end # rubocop:disable Lint/RescueException rescue Exception => e @error = Executor::Error.new(e, self) throw(:result, self) # rubocop:enable Lint/RescueException end end |
#error? ⇒ Boolean
17 |
# File 'lib/sevgi/executor/scope.rb', line 17 def error? = !error.nil? |
#load(file, &block) ⇒ Object
37 |
# File 'lib/sevgi/executor/scope.rb', line 37 def load(file, &block) = call(Source.load(file), &block) |
#peek ⇒ Object
41 |
# File 'lib/sevgi/executor/scope.rb', line 41 def peek = @stack[@stack.keys.last] |
#stack ⇒ Object
39 |
# File 'lib/sevgi/executor/scope.rb', line 39 def stack = @stack.keys |