Class: Steep::Interface::Method

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_name:, name:, types:, super_method:, attributes:) ⇒ Method

Returns a new instance of Method.



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

def initialize(type_name:, name:, types:, super_method:, attributes:)
  @type_name = type_name
  @name = name
  @types = types
  @super_method = super_method
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#super_methodObject (readonly)

Returns the value of attribute super_method.



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

def super_method
  @super_method
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



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

def type_name
  @type_name
end

#typesObject (readonly)

Returns the value of attribute types.



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

def types
  @types
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/steep/interface/method.rb', line 18

def ==(other)
  other.is_a?(Method) &&
    other.type_name == type_name &&
    other.name == name &&
    other.types == types &&
    other.super_method == super_method &&
    other.attributes == attributes
end

#closed?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/steep/interface/method.rb', line 27

def closed?
  types.all?(&:closed?)
end

#include_in_chain?(method) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
57
# File 'lib/steep/interface/method.rb', line 51

def include_in_chain?(method)
  (method.type_name == type_name &&
    method.name == name &&
    method.types == types &&
    method.attributes == attributes) ||
    super_method&.include_in_chain?(method)
end

#subst(s) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/steep/interface/method.rb', line 31

def subst(s)
  self.class.new(
    type_name: type_name,
    name: name,
    types: types.map {|type| type.subst(s) },
    super_method: super_method&.subst(s),
    attributes: attributes
  )
end

#with_super(super_method) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/steep/interface/method.rb', line 41

def with_super(super_method)
  self.class.new(
    type_name: type_name,
    name: name,
    types: types,
    super_method: super_method,
    attributes: attributes
  )
end