Class: DuckTyper::InterfaceChecker::Result

Inherits:
Object
  • Object
show all
Includes:
ResultFormatting
Defined in:
lib/duck_typer/interface_checker/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left:, right:, match:, diff_message:, name:, strict:) ⇒ Result

Returns a new instance of Result.



12
13
14
15
16
17
18
19
# File 'lib/duck_typer/interface_checker/result.rb', line 12

def initialize(left:, right:, match:, diff_message:, name:, strict:)
  @left = left
  @right = right
  @match = match
  @diff_message = diff_message
  @name = name
  @strict = strict
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



10
11
12
# File 'lib/duck_typer/interface_checker/result.rb', line 10

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



10
11
12
# File 'lib/duck_typer/interface_checker/result.rb', line 10

def right
  @right
end

Instance Method Details

#diff_messageObject



25
26
27
# File 'lib/duck_typer/interface_checker/result.rb', line 25

def diff_message
  @diff_message.call
end

#failure_messageObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/duck_typer/interface_checker/result.rb', line 29

def failure_message
  return if match?

  <<~MSG
    Expected #{@left} and #{@right} to implement compatible \
    #{interface_label}, but the following method signatures differ:#{strict_note}

    #{diff_message}
  MSG
end

#match?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/duck_typer/interface_checker/result.rb', line 21

def match?
  @match.call
end