Class: RBS::Definition::Method

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(super_method:, method_types:, defined_in:, implemented_in:, accessibility:, attributes:, annotations:, comment:) ⇒ Method

Returns a new instance of Method.



25
26
27
28
29
30
31
32
33
34
# File 'lib/rbs/definition.rb', line 25

def initialize(super_method:, method_types:, defined_in:, implemented_in:, accessibility:, attributes:, annotations:, comment:)
  @super_method = super_method
  @method_types = method_types
  @defined_in = defined_in
  @implemented_in = implemented_in
  @accessibility = accessibility
  @attributes = attributes
  @annotations = annotations
  @comment = comment
end

Instance Attribute Details

#accessibilityObject (readonly)

Returns the value of attribute accessibility.



20
21
22
# File 'lib/rbs/definition.rb', line 20

def accessibility
  @accessibility
end

#annotationsObject (readonly)

Returns the value of attribute annotations.



22
23
24
# File 'lib/rbs/definition.rb', line 22

def annotations
  @annotations
end

#attributesObject (readonly)

Returns the value of attribute attributes.



21
22
23
# File 'lib/rbs/definition.rb', line 21

def attributes
  @attributes
end

#commentObject (readonly)

Returns the value of attribute comment.



23
24
25
# File 'lib/rbs/definition.rb', line 23

def comment
  @comment
end

#defined_inObject (readonly)

Returns the value of attribute defined_in.



18
19
20
# File 'lib/rbs/definition.rb', line 18

def defined_in
  @defined_in
end

#implemented_inObject (readonly)

Returns the value of attribute implemented_in.



19
20
21
# File 'lib/rbs/definition.rb', line 19

def implemented_in
  @implemented_in
end

#method_typesObject (readonly)

Returns the value of attribute method_types.



17
18
19
# File 'lib/rbs/definition.rb', line 17

def method_types
  @method_types
end

#super_methodObject (readonly)

Returns the value of attribute super_method.



16
17
18
# File 'lib/rbs/definition.rb', line 16

def super_method
  @super_method
end

Instance Method Details

#map_type(&block) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rbs/definition.rb', line 57

def map_type(&block)
  self.class.new(
    super_method: super_method&.map_type(&block),
    method_types: method_types.map do |ty|
      ty.map_type(&block)
    end,
    defined_in: defined_in,
    implemented_in: implemented_in,
    accessibility: @accessibility,
    attributes: attributes,
    annotations: annotations,
    comment: comment
  )
end

#private?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/rbs/definition.rb', line 40

def private?
  @accessibility == :private
end

#public?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/rbs/definition.rb', line 36

def public?
  @accessibility == :public
end

#sub(s) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rbs/definition.rb', line 44

def sub(s)
  self.class.new(
    super_method: super_method&.sub(s),
    method_types: method_types.map {|ty| ty.sub(s) },
    defined_in: defined_in,
    implemented_in: implemented_in,
    accessibility: @accessibility,
    attributes: attributes,
    annotations: annotations,
    comment: comment
  )
end