Class: Steep::Interface::Function::Params::PositionalParams::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/steep/interface/function.rb

Direct Known Subclasses

Optional, Required, Rest

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ Base

Returns a new instance of Base.



20
21
22
# File 'lib/steep/interface/function.rb', line 20

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



18
19
20
# File 'lib/steep/interface/function.rb', line 18

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



24
25
26
# File 'lib/steep/interface/function.rb', line 24

def ==(other)
  other.is_a?(self.class) && other.type == type
end

#hashObject



30
31
32
# File 'lib/steep/interface/function.rb', line 30

def hash
  self.class.hash ^ type.hash
end

#map_type(&block) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/steep/interface/function.rb', line 48

def map_type(&block)
  if block_given?
    _ = self.class.new(yield type)
  else
    enum_for(:map_type)
  end
end

#subst(s) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/steep/interface/function.rb', line 34

def subst(s)
  ty = type.subst(s)

  if ty == type
    self
  else
    _ = self.class.new(ty)
  end
end

#var_typeObject



44
45
46
# File 'lib/steep/interface/function.rb', line 44

def var_type
  type
end