Class: Stretchy::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/stretchy/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contextObject (readonly)

Returns the value of attribute context.



4
5
6
# File 'lib/stretchy/node.rb', line 4

def context
  @context
end

#jsonObject (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

Returns:

  • (Boolean)


16
17
18
# File 'lib/stretchy/node.rb', line 16

def context?(*args)
  args.all? {|c| !!context[c] }
end

#empty?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/stretchy/node.rb', line 12

def empty?
  !@json.any?
end