Class: ScopedHash
- Inherits:
-
Mash
- Object
- Mash
- ScopedHash
- Defined in:
- lib/scoped_hash.rb
Constant Summary collapse
- DEFAULT_LEFT_BRACKET =
'('- DEFAULT_RIGHT_BRACKET =
')'
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ ScopedHash
constructor
A new instance of ScopedHash.
- #scope(scope) ⇒ Object
- #set_bracket(bracket) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ ScopedHash
Returns a new instance of ScopedHash.
7 8 9 10 11 12 |
# File 'lib/scoped_hash.rb', line 7 def initialize(args = {}) super args @lbracket = DEFAULT_LEFT_BRACKET @rbracket = DEFAULT_RIGHT_BRACKET end |
Instance Method Details
#scope(scope) ⇒ Object
14 15 16 17 18 |
# File 'lib/scoped_hash.rb', line 14 def scope(scope) mash = self.clone() visit_scope(mash, scope) return mash end |
#set_bracket(bracket) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/scoped_hash.rb', line 20 def set_bracket(bracket) if bracket.length != 2 raise "Bracket length should be 2" end @lbracket = bracket[0] @rbracket = bracket[1] end |