Class: Contracts::DefaultErrorFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/contracts/error_formatter.rb

Direct Known Subclasses

KeywordArgsErrorFormatter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ DefaultErrorFormatter

Returns a new instance of DefaultErrorFormatter.



22
23
24
# File 'lib/contracts/error_formatter.rb', line 22

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



21
22
23
# File 'lib/contracts/error_formatter.rb', line 21

def data
  @data
end

Instance Method Details

#messageObject



26
27
28
29
30
31
32
33
# File 'lib/contracts/error_formatter.rb', line 26

def message
  %{#{header}
    Expected: #{expected},
    Actual: #{data[:arg].inspect}
    Value guarded in: #{data[:class]}::#{method_name}
    With Contract: #{data[:contracts]}
    At: #{position} }
end