Class: Hiptest::Nodes::Node
- Inherits:
-
Object
- Object
- Hiptest::Nodes::Node
show all
- Defined in:
- lib/hiptest-publisher/nodes.rb
Direct Known Subclasses
Actionwords, Argument, Assign, BinaryExpression, Call, Dataset, Datatable, Dict, Field, Folder, IfThen, Index, Item, Libraries, Library, List, Literal, NullLiteral, Parameter, Parenthesis, Project, Property, Scenarios, Step, Symbol, Tag, Template, Test, TestPlan, Tests, UnaryExpression, Variable, While
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
10
11
12
|
# File 'lib/hiptest-publisher/nodes.rb', line 10
def children
@children
end
|
#parent ⇒ Object
Returns the value of attribute parent.
10
11
12
|
# File 'lib/hiptest-publisher/nodes.rb', line 10
def parent
@parent
end
|
Instance Method Details
#==(other) ⇒ Object
54
55
56
|
# File 'lib/hiptest-publisher/nodes.rb', line 54
def ==(other)
other.class == self.class && other.children == @children
end
|
#each_direct_children ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/hiptest-publisher/nodes.rb', line 44
def each_direct_children
children.each_value do |child|
if child.is_a? Hiptest::Nodes::Node
yield child
elsif child.is_a? Array
child.each {|c| yield c if c.is_a? Hiptest::Nodes::Node }
end
end
end
|
#each_sub_nodes(*types, deep: false) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/hiptest-publisher/nodes.rb', line 21
def each_sub_nodes(*types, deep: false)
return to_enum(:each_sub_nodes, *types, deep: deep) unless block_given?
path = [self]
parsed_nodes_id = Set.new
until path.empty?
current_node = path.shift
if current_node.is_a?(Node)
next if parsed_nodes_id.include? current_node.object_id
parsed_nodes_id << current_node.object_id
if types.empty? || types.any? {|type| current_node.is_a?(type)}
yield current_node
next unless deep
end
current_node.children.each_value {|item| path << item}
elsif current_node.is_a?(Array)
current_node.each {|item| path << item}
end
end
end
|
#flat_string ⇒ Object
72
73
74
75
76
77
|
# File 'lib/hiptest-publisher/nodes.rb', line 72
def flat_string
flat_childs = children.map do |key, value|
"#{key}: #{flatten_child(value)}"
end.join(", ")
"<#{self.class.name} [#{flat_childs}]>"
end
|
#kind ⇒ Object
66
67
68
69
70
|
# File 'lib/hiptest-publisher/nodes.rb', line 66
def kind
node_kinds[self.class] ||= begin
self.class.name.split('::').last.downcase
end
end
|
#pretty_print_instance_variables ⇒ Object
13
14
15
|
# File 'lib/hiptest-publisher/nodes.rb', line 13
def pretty_print_instance_variables
super - [:@parent] end
|
#project ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/hiptest-publisher/nodes.rb', line 58
def project
project = self
while project && !project.is_a?(Hiptest::Nodes::Project)
project = project.parent
end
project
end
|
#render(rendering_context) ⇒ Object
17
18
19
|
# File 'lib/hiptest-publisher/nodes.rb', line 17
def render(rendering_context)
return Hiptest::Renderer.render(self, rendering_context)
end
|