Class: Steep::Interface::Abstract

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, params:, methods:, supers:, ivar_chains:) ⇒ Abstract

Returns a new instance of Abstract.



11
12
13
14
15
16
17
# File 'lib/steep/interface/abstract.rb', line 11

def initialize(name:, params:, methods:, supers:, ivar_chains:)
  @name = name
  @params = params
  @methods = methods
  @supers = supers
  @ivar_chains = ivar_chains
end

Instance Attribute Details

#ivar_chainsObject (readonly)

Returns the value of attribute ivar_chains.



9
10
11
# File 'lib/steep/interface/abstract.rb', line 9

def ivar_chains
  @ivar_chains
end

#kindObject (readonly)

Returns the value of attribute kind.



5
6
7
# File 'lib/steep/interface/abstract.rb', line 5

def kind
  @kind
end

#methodsObject (readonly)

Returns the value of attribute methods.



7
8
9
# File 'lib/steep/interface/abstract.rb', line 7

def methods
  @methods
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/steep/interface/abstract.rb', line 4

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'lib/steep/interface/abstract.rb', line 6

def params
  @params
end

#supersObject (readonly)

Returns the value of attribute supers.



8
9
10
# File 'lib/steep/interface/abstract.rb', line 8

def supers
  @supers
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/steep/interface/abstract.rb', line 23

def ==(other)
  other.is_a?(self.class) &&
    other.name == name &&
    other.params == params &&
    other.methods == methods &&
    other.supers == supers &&
    other.ivars == ivars
end

#instantiate(type:, args:, instance_type:, module_type:) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/steep/interface/abstract.rb', line 32

def instantiate(type:, args:, instance_type:, module_type:)
  Steep.logger.debug("type=#{type}, self=#{name}, args=#{args}, params=#{params}")
  subst = Substitution.build(params, args, instance_type: instance_type, module_type: module_type, self_type: type)

  Instantiated.new(
    type: type,
    methods: methods.transform_values {|method| method.subst(subst) },
    ivar_chains: ivar_chains.transform_values {|chain| chain.subst(subst) }
  )
end

#ivarsObject



19
20
21
# File 'lib/steep/interface/abstract.rb', line 19

def ivars
  @ivars ||= ivar_chains.transform_values(&:type)
end