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

Inherits:
Object
  • 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:) ⇒ MethodDefinition

Returns a new instance of MethodDefinition.



13
14
15
16
17
18
19
20
21
# File 'lib/rbs/ast/members.rb', line 13

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

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations.



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

def annotations
  @annotations
end

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#commentObject (readonly)

Returns the value of attribute comment.



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

def comment
  @comment
end

#kindObject (readonly)

Returns the value of attribute kind.



6
7
8
# File 'lib/rbs/ast/members.rb', line 6

def kind
  @kind
end

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/rbs/ast/members.rb', line 5

def name
  @name
end

#typesObject (readonly)

Returns the value of attribute types.



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

def types
  @types
end

Instance Method Details

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



23
24
25
26
27
28
29
# File 'lib/rbs/ast/members.rb', line 23

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

#hashObject



33
34
35
# File 'lib/rbs/ast/members.rb', line 33

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

#instance?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rbs/ast/members.rb', line 37

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

#singleton?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/rbs/ast/members.rb', line 41

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

#to_json(*a) ⇒ Object



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

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