Class: SuperDiff::Core::InspectionTreeNodes::OnlyWhen

Inherits:
Base
  • Object
show all
Defined in:
lib/super_diff/core/inspection_tree_nodes/only_when.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#clone_with, #pretty_print, #render

Constructor Details

#initialize(tree, test, **options, &block) ⇒ OnlyWhen

Returns a new instance of OnlyWhen.



15
16
17
18
19
20
21
22
# File 'lib/super_diff/core/inspection_tree_nodes/only_when.rb', line 15

def initialize(tree, test, **options, &block)
  super(tree, **options, &block)

  @tree = tree
  @test = test
  @block = block
  @options = options
end

Class Method Details

.method_nameObject



11
12
13
# File 'lib/super_diff/core/inspection_tree_nodes/only_when.rb', line 11

def self.method_name
  :only_when
end

.node_nameObject



7
8
9
# File 'lib/super_diff/core/inspection_tree_nodes/only_when.rb', line 7

def self.node_name
  :only_when
end

Instance Method Details

#render_to_lines(object, type:, indentation_level:) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/super_diff/core/inspection_tree_nodes/only_when.rb', line 28

def render_to_lines(object, type:, indentation_level:)
  if test_passes?
    render_to_lines_in_subtree(
      object,
      type: type,
      indentation_level: indentation_level
    )
  else
    []
  end
end

#render_to_string(object) ⇒ Object



24
25
26
# File 'lib/super_diff/core/inspection_tree_nodes/only_when.rb', line 24

def render_to_string(object)
  test_passes? ? render_to_string_in_subtree(object) : ''
end