Class: Yoda::Model::TypeExpressions::DuckType

Inherits:
Base
  • Object
show all
Defined in:
lib/yoda/model/type_expressions/duck_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, #map

Constructor Details

#initialize(method_name) ⇒ DuckType

Returns a new instance of DuckType.

Parameters:

  • method_name (String)


8
9
10
# File 'lib/yoda/model/type_expressions/duck_type.rb', line 8

def initialize(method_name)
  @method_name = method_name
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



5
6
7
# File 'lib/yoda/model/type_expressions/duck_type.rb', line 5

def method_name
  @method_name
end

Instance Method Details

#change_root(paths) ⇒ self

Parameters:

Returns:

  • (self)


24
25
26
# File 'lib/yoda/model/type_expressions/duck_type.rb', line 24

def change_root(paths)
  self
end

#eql?(another) ⇒ Boolean

Parameters:

  • another (Object)

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/yoda/model/type_expressions/duck_type.rb', line 13

def eql?(another)
  another.is_a?(DuckType) &&
  method_name == another.method_name
end

#hashObject



18
19
20
# File 'lib/yoda/model/type_expressions/duck_type.rb', line 18

def hash
  [self.class.name, method_name].hash
end

#resolve(registry) ⇒ Array<Store::Objects::Base>

Parameters:

  • registry (Registry)

Returns:



30
31
32
# File 'lib/yoda/model/type_expressions/duck_type.rb', line 30

def resolve(registry)
  []
end

#to_rbs_type(env) ⇒ Object

Parameters:



35
36
37
38
# File 'lib/yoda/model/type_expressions/duck_type.rb', line 35

def to_rbs_type(env)
  # TODO: Implement as interface type
  RBS::Types::Bases::Any.new(location: nil)
end

#to_sString

Returns:

  • (String)


41
42
43
# File 'lib/yoda/model/type_expressions/duck_type.rb', line 41

def to_s
  "##{method_name}"
end