Class: RBS::AST::Members::MethodDefinition

Inherits:
Base
  • Object
show all
Defined in:
lib/rbs/ast/members.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, kind:, types:, annotations:, location:, comment:, attributes:, overload:) ⇒ MethodDefinition

Returns a new instance of MethodDefinition.



17
18
19
20
21
22
23
24
25
26
# File 'lib/rbs/ast/members.rb', line 17

def initialize(name:, kind:, types:, annotations:, location:, comment:, attributes:, overload:)
  @name = name
  @kind = kind
  @types = types
  @annotations = annotations
  @location = location
  @comment = comment
  @attributes = attributes
  @overload = overload
end

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations.



11
12
13
# File 'lib/rbs/ast/members.rb', line 11

def annotations
  @annotations
end

#attributesObject (readonly)

Returns the value of attribute attributes.



14
15
16
# File 'lib/rbs/ast/members.rb', line 14

def attributes
  @attributes
end

#commentObject (readonly)

Returns the value of attribute comment.



13
14
15
# File 'lib/rbs/ast/members.rb', line 13

def comment
  @comment
end

#kindObject (readonly)

Returns the value of attribute kind.



9
10
11
# File 'lib/rbs/ast/members.rb', line 9

def kind
  @kind
end

#locationObject (readonly)

Returns the value of attribute location.



12
13
14
# File 'lib/rbs/ast/members.rb', line 12

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/rbs/ast/members.rb', line 8

def name
  @name
end

#overloadObject (readonly)

Returns the value of attribute overload.



15
16
17
# File 'lib/rbs/ast/members.rb', line 15

def overload
  @overload
end

#typesObject (readonly)

Returns the value of attribute types.



10
11
12
# File 'lib/rbs/ast/members.rb', line 10

def types
  @types
end

Instance Method Details

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



28
29
30
31
32
33
34
35
# File 'lib/rbs/ast/members.rb', line 28

def ==(other)
  other.is_a?(MethodDefinition) &&
    other.name == name &&
    other.kind == kind &&
    other.types == types &&
    other.attributes == attributes &&
    other.overload == overload
end

#hashObject



39
40
41
# File 'lib/rbs/ast/members.rb', line 39

def hash
  self.class.hash ^ name.hash ^ kind.hash ^ types.hash ^ attributes.hash ^ overload.hash
end

#instance?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/rbs/ast/members.rb', line 43

def instance?
  kind == :instance || kind == :singleton_instance
end

#overload?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/rbs/ast/members.rb', line 51

def overload?
  overload
end

#singleton?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/rbs/ast/members.rb', line 47

def singleton?
  kind == :singleton || kind == :singleton_instance
end

#to_json(*a) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/rbs/ast/members.rb', line 68

def to_json(*a)
  {
    member: :method_definition,
    kind: kind,
    types: types,
    annotations: annotations,
    location: location,
    comment: comment,
    attributes: attributes,
    overload: overload
  }.to_json(*a)
end

#update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, attributes: self.attributes, overload: self.overload) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rbs/ast/members.rb', line 55

def update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, attributes: self.attributes, overload: self.overload)
  self.class.new(
    name: name,
    kind: kind,
    types: types,
    annotations: annotations,
    location: location,
    comment: comment,
    attributes: attributes,
    overload: overload
  )
end