Class: Rucoa::Rbs::MethodDefinitionMapper::MethodTypeMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/rucoa/rbs/method_definition_mapper.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_type:) ⇒ MethodTypeMapper

Returns a new instance of MethodTypeMapper.

Parameters:

  • method_type (RBS::Types::MethodType)


95
96
97
# File 'lib/rucoa/rbs/method_definition_mapper.rb', line 95

def initialize(method_type:)
  @method_type = method_type
end

Class Method Details

.call(method_type:) ⇒ Rucoa::Types::MethodType

Parameters:

  • method_type (RBS::Types::MethodType)

Returns:



83
84
85
# File 'lib/rucoa/rbs/method_definition_mapper.rb', line 83

def call(method_type:)
  new(method_type: method_type).call
end

.stringify(type) ⇒ String

Parameters:

  • type (RBS::Types::Base)

Returns:

  • (String)


89
90
91
# File 'lib/rucoa/rbs/method_definition_mapper.rb', line 89

def stringify(type)
  type.to_s.delete_prefix('::')
end

Instance Method Details

#callRucoa::Types::MethodType



100
101
102
103
104
105
# File 'lib/rucoa/rbs/method_definition_mapper.rb', line 100

def call
  Types::MethodType.new(
    parameters_string: @method_type.type.param_to_s,
    return_type: self.class.stringify(@method_type.type.return_type)
  )
end