Class: Parslet::Scope::Binding
- Inherits:
-
Object
- Object
- Parslet::Scope::Binding
- Defined in:
- lib/parslet/scope.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
-
#initialize(parent = nil) ⇒ Binding
constructor
A new instance of Binding.
Constructor Details
#initialize(parent = nil) ⇒ Binding
Returns a new instance of Binding.
10 11 12 13 |
# File 'lib/parslet/scope.rb', line 10 def initialize(parent=nil) @parent = parent @hash = Hash.new end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
8 9 10 |
# File 'lib/parslet/scope.rb', line 8 def parent @parent end |
Instance Method Details
#[](k) ⇒ Object
15 16 17 18 19 |
# File 'lib/parslet/scope.rb', line 15 def [](k) @hash.has_key?(k) && @hash[k] || parent && parent[k] or raise NotFound end |
#[]=(k, v) ⇒ Object
20 21 22 |
# File 'lib/parslet/scope.rb', line 20 def []=(k,v) @hash.store(k,v) end |