Class: RBS::AST::Members::MethodDefinition
- Defined in:
- lib/rbs/ast/members.rb
Instance Attribute Summary collapse
-
#annotations ⇒ Object
readonly
Returns the value of attribute annotations.
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#overload ⇒ Object
readonly
Returns the value of attribute overload.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
-
#visibility ⇒ Object
readonly
Returns the value of attribute visibility.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name:, kind:, types:, annotations:, location:, comment:, overload:, visibility: nil) ⇒ MethodDefinition
constructor
A new instance of MethodDefinition.
- #instance? ⇒ Boolean
- #overload? ⇒ Boolean
- #singleton? ⇒ Boolean
- #to_json(state = _ = nil) ⇒ Object
- #update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, overload: self.overload, visibility: self.visibility) ⇒ Object
Constructor Details
#initialize(name:, kind:, types:, annotations:, location:, comment:, overload:, visibility: nil) ⇒ MethodDefinition
Returns a new instance of MethodDefinition.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rbs/ast/members.rb', line 19 def initialize(name:, kind:, types:, annotations:, location:, comment:, overload:, visibility: nil) @name = name @kind = kind @types = types @annotations = annotations @location = location @comment = comment @overload = overload ? true : false @visibility = visibility end |
Instance Attribute Details
#annotations ⇒ Object (readonly)
Returns the value of attribute annotations.
13 14 15 |
# File 'lib/rbs/ast/members.rb', line 13 def annotations @annotations end |
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
15 16 17 |
# File 'lib/rbs/ast/members.rb', line 15 def comment @comment end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
11 12 13 |
# File 'lib/rbs/ast/members.rb', line 11 def kind @kind end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
14 15 16 |
# File 'lib/rbs/ast/members.rb', line 14 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/rbs/ast/members.rb', line 10 def name @name end |
#overload ⇒ Object (readonly)
Returns the value of attribute overload.
16 17 18 |
# File 'lib/rbs/ast/members.rb', line 16 def overload @overload end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
12 13 14 |
# File 'lib/rbs/ast/members.rb', line 12 def types @types end |
#visibility ⇒ Object (readonly)
Returns the value of attribute visibility.
17 18 19 |
# File 'lib/rbs/ast/members.rb', line 17 def visibility @visibility end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
30 31 32 33 34 35 36 37 |
# File 'lib/rbs/ast/members.rb', line 30 def ==(other) other.is_a?(MethodDefinition) && other.name == name && other.kind == kind && other.types == types && other.overload == overload && other.visibility == visibility end |
#hash ⇒ Object
41 42 43 |
# File 'lib/rbs/ast/members.rb', line 41 def hash name.hash ^ kind.hash ^ types.hash ^ overload.hash end |
#instance? ⇒ Boolean
45 46 47 |
# File 'lib/rbs/ast/members.rb', line 45 def instance? kind == :instance || kind == :singleton_instance end |
#overload? ⇒ Boolean
53 54 55 |
# File 'lib/rbs/ast/members.rb', line 53 def overload? overload end |
#singleton? ⇒ Boolean
49 50 51 |
# File 'lib/rbs/ast/members.rb', line 49 def singleton? kind == :singleton || kind == :singleton_instance end |
#to_json(state = _ = nil) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/rbs/ast/members.rb', line 70 def to_json(state = _ = nil) { member: :method_definition, name: name, kind: kind, types: types, annotations: annotations, location: location, comment: comment, overload: overload, visibility: visibility }.to_json(state) end |
#update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, overload: self.overload, visibility: self.visibility) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rbs/ast/members.rb', line 57 def update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, overload: self.overload, visibility: self.visibility) self.class.new( name: name, kind: kind, types: types, annotations: annotations, location: location, comment: comment, overload: overload, visibility: visibility ) end |