Class: Rusty::Scope
Overview
A Rusty output scope, is related to a input node, and might or might not have a parent.
Constant Summary
Constants inherited from DX
DX::EXCLUSIVE_DICT_METHODS, DX::EXCLUSIVE_LIST_METHODS
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
-
#has_name?(name) ⇒ Boolean
Does this scope matches a given name?.
-
#initialize(node, parent = nil) ⇒ Scope
constructor
A new instance of Scope.
-
#up! {|_self| ... } ⇒ Object
yields all nodes starting at self up to the top.
Methods inherited from DX
#dict?, #inspect, #list?, #method_missing, to_ruby, #to_ruby
Constructor Details
#initialize(node, parent = nil) ⇒ Scope
Returns a new instance of Scope.
13 14 15 |
# File 'lib/rusty/scope.rb', line 13 def initialize(node, parent=nil) @node, @parent = node, parent end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rusty::DX
Instance Attribute Details
#node ⇒ Object
Returns the value of attribute node.
10 11 12 |
# File 'lib/rusty/scope.rb', line 10 def node @node end |
Instance Method Details
#has_name?(name) ⇒ Boolean
Does this scope matches a given name?
18 19 20 21 22 |
# File 'lib/rusty/scope.rb', line 18 def has_name?(name) return @parent.nil? if name == "document" node.name == name || node.has_class?(name) end |
#up! {|_self| ... } ⇒ Object
yields all nodes starting at self up to the top.
25 26 27 28 |
# File 'lib/rusty/scope.rb', line 25 def up!(&block) yield(self) @parent.up!(&block) if @parent end |