Class: Stretchy::Node
- Inherits:
-
Object
- Object
- Stretchy::Node
- Defined in:
- lib/stretchy/node.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#json ⇒ Object
(also: #as_json)
readonly
Returns the value of attribute json.
Instance Method Summary collapse
- #context?(*args) ⇒ Boolean
- #empty? ⇒ Boolean
-
#initialize(json, context = {}) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(json, context = {}) ⇒ Node
Returns a new instance of Node.
7 8 9 10 |
# File 'lib/stretchy/node.rb', line 7 def initialize(json, context = {}) @json = json @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/stretchy/node.rb', line 4 def context @context end |
#json ⇒ Object (readonly) Also known as: as_json
Returns the value of attribute json.
4 5 6 |
# File 'lib/stretchy/node.rb', line 4 def json @json end |
Instance Method Details
#context?(*args) ⇒ Boolean
16 17 18 |
# File 'lib/stretchy/node.rb', line 16 def context?(*args) args.all? {|c| !!context[c] } end |
#empty? ⇒ Boolean
12 13 14 |
# File 'lib/stretchy/node.rb', line 12 def empty? !@json.any? end |