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

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

Defined Under Namespace

Classes: Overload

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, kind:, overloads:, annotations:, location:, comment:, overloading:, visibility:) ⇒ MethodDefinition

Returns a new instance of MethodDefinition.



53
54
55
56
57
58
59
60
61
62
# File 'lib/rbs/ast/members.rb', line 53

def initialize(name:, kind:, overloads:, annotations:, location:, comment:, overloading:, visibility:)
  @name = name
  @kind = kind
  @overloads = overloads
  @annotations = annotations
  @location = location
  @comment = comment
  @overloading = overloading
  @visibility = visibility
end

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations.



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

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



49
50
51
# File 'lib/rbs/ast/members.rb', line 49

def comment
  @comment
end

#kindObject (readonly)

Returns the value of attribute kind.



45
46
47
# File 'lib/rbs/ast/members.rb', line 45

def kind
  @kind
end

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#overloadingObject (readonly)

Returns the value of attribute overloading.



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

def overloading
  @overloading
end

#overloadsObject (readonly)

Returns the value of attribute overloads.



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

def overloads
  @overloads
end

#visibilityObject (readonly)

Returns the value of attribute visibility.



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

def visibility
  @visibility
end

Instance Method Details

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



64
65
66
67
68
69
70
71
# File 'lib/rbs/ast/members.rb', line 64

def ==(other)
  other.is_a?(MethodDefinition) &&
    other.name == name &&
    other.kind == kind &&
    other.overloads == overloads &&
    other.overloading? == overloading? &&
    other.visibility == visibility
end

#hashObject



75
76
77
# File 'lib/rbs/ast/members.rb', line 75

def hash
  name.hash ^ kind.hash ^ overloads.hash ^ overloading?.hash ^ visibility.hash
end

#instance?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/rbs/ast/members.rb', line 79

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

#overloading?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/rbs/ast/members.rb', line 87

def overloading?
  overloading
end

#singleton?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/rbs/ast/members.rb', line 83

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

#to_json(state = _ = nil) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/rbs/ast/members.rb', line 104

def to_json(state = _ = nil)
  {
    member: :method_definition,
    name: name,
    kind: kind,
    overloads: overloads,
    annotations: annotations,
    location: location,
    comment: comment,
    overloading: overloading?,
    visibility: visibility
  }.to_json(state)
end

#update(name: self.name, kind: self.kind, overloads: self.overloads, annotations: self.annotations, location: self.location, comment: self.comment, overloading: self.overloading?, visibility: self.visibility) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/rbs/ast/members.rb', line 91

def update(name: self.name, kind: self.kind, overloads: self.overloads, annotations: self.annotations, location: self.location, comment: self.comment, overloading: self.overloading?, visibility: self.visibility)
  self.class.new(
    name: name,
    kind: kind,
    overloads: overloads,
    annotations: annotations,
    location: location,
    comment: comment,
    overloading: overloading,
    visibility: visibility
  )
end