Class: Steep::Errors::MethodBodyTypeMismatch

Inherits:
Base
  • Object
show all
Includes:
ResultPrinter
Defined in:
lib/steep/errors.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#node

Instance Method Summary collapse

Methods included from ResultPrinter

#print_result_to, #print_to

Methods inherited from Base

#location_to_str, #print_to

Constructor Details

#initialize(node:, expected:, actual:, result:) ⇒ MethodBodyTypeMismatch

Returns a new instance of MethodBodyTypeMismatch.



307
308
309
310
311
312
# File 'lib/steep/errors.rb', line 307

def initialize(node:, expected:, actual:, result:)
  super(node: node)
  @expected = expected
  @actual = actual
  @result = result
end

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



302
303
304
# File 'lib/steep/errors.rb', line 302

def actual
  @actual
end

#expectedObject (readonly)

Returns the value of attribute expected.



301
302
303
# File 'lib/steep/errors.rb', line 301

def expected
  @expected
end

#resultObject (readonly)

Returns the value of attribute result.



303
304
305
# File 'lib/steep/errors.rb', line 303

def result
  @result
end

Instance Method Details

#to_sObject



314
315
316
317
318
319
320
321
322
323
# File 'lib/steep/errors.rb', line 314

def to_s
  method = case node.type
           when :def
             node.children[0]
           when :defs
             prefix = node.children[0].type == :self ? "self" : "*"
             "#{prefix}.#{node.children[1]}"
           end
  "#{location_to_str}: MethodBodyTypeMismatch: method=#{method}, expected=#{expected}, actual=#{actual}"
end