Class: Hiptest::Nodes::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/hiptest-publisher/nodes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



8
9
10
# File 'lib/hiptest-publisher/nodes.rb', line 8

def children
  @children
end

#parentObject

Returns the value of attribute parent.



8
9
10
# File 'lib/hiptest-publisher/nodes.rb', line 8

def parent
  @parent
end

Instance Method Details

#direct_childrenObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/hiptest-publisher/nodes.rb', line 28

def direct_children
  direct = []

  children.each do |key, child|
    if child.is_a? Hiptest::Nodes::Node
      direct << child
    elsif child.is_a? Array
      child.each {|c| direct << c if c.is_a? Hiptest::Nodes::Node }
    end
  end

  direct
end

#find_sub_nodes(types = []) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hiptest-publisher/nodes.rb', line 15

def find_sub_nodes(types = [])
  sub_nodes = all_sub_nodes
  types = [types] unless types.is_a?(Array)

  if types.empty?
    sub_nodes
  else
    sub_nodes.keep_if do |node|
      types.map {|type| node.is_a?(type)}.include?(true)
    end
  end
end

#render(language = 'ruby', context = {}) ⇒ Object



11
12
13
# File 'lib/hiptest-publisher/nodes.rb', line 11

def render(language = 'ruby', context = {})
  return Hiptest::Renderer.render(self, language, context)
end