Class: SuperDiff::Core::InspectionTreeNodes::AsLinesWhenRenderingToLines
- Inherits:
-
Base
- Object
- Base
- SuperDiff::Core::InspectionTreeNodes::AsLinesWhenRenderingToLines
show all
- Defined in:
- lib/super_diff/core/inspection_tree_nodes/as_lines_when_rendering_to_lines.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#clone_with, #pretty_print, #render
Constructor Details
#initialize(tree, *args, add_comma: false, collection_bookend: nil, **rest, &block) ⇒ AsLinesWhenRenderingToLines
Returns a new instance of AsLinesWhenRenderingToLines.
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/super_diff/core/inspection_tree_nodes/as_lines_when_rendering_to_lines.rb', line 15
def initialize(
tree,
*args,
add_comma: false,
collection_bookend: nil,
**rest,
&block
)
super(tree, *args, **rest, &block)
@add_comma = add_comma
@collection_bookend = collection_bookend
end
|
Class Method Details
.method_name ⇒ Object
11
12
13
|
# File 'lib/super_diff/core/inspection_tree_nodes/as_lines_when_rendering_to_lines.rb', line 11
def self.method_name
:as_lines_when_rendering_to_lines
end
|
.node_name ⇒ Object
7
8
9
|
# File 'lib/super_diff/core/inspection_tree_nodes/as_lines_when_rendering_to_lines.rb', line 7
def self.node_name
:as_lines_when_rendering_to_lines
end
|
Instance Method Details
#render_to_lines(object, type:, indentation_level:) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/super_diff/core/inspection_tree_nodes/as_lines_when_rendering_to_lines.rb', line 43
def render_to_lines(object, type:, indentation_level:)
lines =
if block
render_to_lines_in_subtree(
object,
type: type,
indentation_level: indentation_level,
disallowed_node_names: %i[line as_lines_when_rendering_to_lines]
)
else
[
SuperDiff::Line.new(
type: type,
indentation_level: indentation_level,
value: immediate_value.to_s
)
]
end
with_collection_bookend_added_to_last_line_in(
with_add_comma_added_to_last_line_in(lines)
)
end
|
#render_to_string(object) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/super_diff/core/inspection_tree_nodes/as_lines_when_rendering_to_lines.rb', line 29
def render_to_string(object)
string =
(
if block
render_to_string_in_subtree(object)
else
immediate_value.to_s
end
)
add_comma? ? "#{string}," : string
end
|