Class: SuperDiff::ObjectInspection::Nodes::Base
Direct Known Subclasses
AsLinesWhenRenderingToLines, AsPrefixWhenRenderingToLines, AsPreludeWhenRenderingToLines, AsSingleLine, Inspection, Nesting, OnlyWhen, Text, WhenEmpty, WhenNonEmpty, WhenRenderingToLines, WhenRenderingToString
Class Method Summary
collapse
Instance Method Summary
collapse
-
#clone_with(tree: @tree, immediate_value: @immediate_value, block: @block, **rest) ⇒ Object
-
#initialize(tree, *args, **options, &block) ⇒ Base
constructor
-
#pretty_print(pp) ⇒ Object
-
#render(object, preferably_as_lines:, **rest) ⇒ Object
-
#render_to_lines(object, type:, indentation_level:) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
#render_to_string(object) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
Constructor Details
#initialize(tree, *args, **options, &block) ⇒ Base
Returns a new instance of Base.
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/super_diff/object_inspection/nodes/base.rb', line 16
def initialize(tree, *args, **options, &block)
if !args.empty? && block
raise ArgumentError.new(
"You cannot provide both an immediate value and a lazy value. " +
"Either pass a block or a positional argument."
)
end
@tree = tree
@immediate_value = args.first
@block = block
@options = options
end
|
Class Method Details
.method_name ⇒ Object
9
10
11
|
# File 'lib/super_diff/object_inspection/nodes/base.rb', line 9
def self.method_name
unimplemented_class_method!
end
|
.node_name ⇒ Object
5
6
7
|
# File 'lib/super_diff/object_inspection/nodes/base.rb', line 5
def self.node_name
unimplemented_class_method!
end
|
Instance Method Details
#clone_with(tree: @tree, immediate_value: @immediate_value, block: @block, **rest) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/super_diff/object_inspection/nodes/base.rb', line 30
def clone_with(
tree: @tree,
immediate_value: @immediate_value,
block: @block,
**rest
)
if block
self.class.new(tree, **options, **rest, &block)
else
self.class.new(tree, immediate_value, **options, **rest)
end
end
|
#pretty_print(pp) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/super_diff/object_inspection/nodes/base.rb', line 63
def pretty_print(pp)
pp.object_address_group(self) do
pp.seplist(pretty_print_variables, proc { pp.text "," }) do |name|
value = instance_variable_get(name)
pp.breakable " "
pp.group(1) do
pp.text name[1..-1].to_s
pp.text ":"
pp.breakable
pp.pp value
end
end
end
end
|
#render(object, preferably_as_lines:, **rest) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/super_diff/object_inspection/nodes/base.rb', line 43
def render(object, preferably_as_lines:, **rest)
if options[:as_lines] || preferably_as_lines
render_to_lines(object, **rest)
else
render_to_string(object)
end
end
|
#render_to_lines(object, type:, indentation_level:) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
58
59
60
61
|
# File 'lib/super_diff/object_inspection/nodes/base.rb', line 58
def render_to_lines(object, type:, indentation_level:)
unimplemented_instance_method!
end
|
#render_to_string(object) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
52
53
54
55
|
# File 'lib/super_diff/object_inspection/nodes/base.rb', line 52
def render_to_string(object)
unimplemented_instance_method!
end
|