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.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name:, kind:, types:, annotations:, location:, comment:, overload:) ⇒ 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) ⇒ Object
Constructor Details
permalink #initialize(name:, kind:, types:, annotations:, location:, comment:, overload:) ⇒ MethodDefinition
Returns a new instance of MethodDefinition.
16 17 18 19 20 21 22 23 24 |
# File 'lib/rbs/ast/members.rb', line 16 def initialize(name:, kind:, types:, annotations:, location:, comment:, overload:) @name = name @kind = kind @types = types @annotations = annotations @location = location @comment = comment @overload = overload ? true : false end |
Instance Attribute Details
permalink #annotations ⇒ Object (readonly)
Returns the value of attribute annotations.
11 12 13 |
# File 'lib/rbs/ast/members.rb', line 11 def annotations @annotations end |
permalink #comment ⇒ Object (readonly)
Returns the value of attribute comment.
13 14 15 |
# File 'lib/rbs/ast/members.rb', line 13 def comment @comment end |
permalink #kind ⇒ Object (readonly)
Returns the value of attribute kind.
9 10 11 |
# File 'lib/rbs/ast/members.rb', line 9 def kind @kind end |
permalink #location ⇒ Object (readonly)
Returns the value of attribute location.
12 13 14 |
# File 'lib/rbs/ast/members.rb', line 12 def location @location end |
permalink #name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/rbs/ast/members.rb', line 8 def name @name end |
permalink #overload ⇒ Object (readonly)
Returns the value of attribute overload.
14 15 16 |
# File 'lib/rbs/ast/members.rb', line 14 def overload @overload end |
permalink #types ⇒ Object (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
permalink #==(other) ⇒ Object Also known as: eql?
[View source]
26 27 28 29 30 31 32 |
# File 'lib/rbs/ast/members.rb', line 26 def ==(other) other.is_a?(MethodDefinition) && other.name == name && other.kind == kind && other.types == types && other.overload == overload end |
permalink #hash ⇒ Object
[View source]
36 37 38 |
# File 'lib/rbs/ast/members.rb', line 36 def hash self.class.hash ^ name.hash ^ kind.hash ^ types.hash ^ overload.hash end |
permalink #instance? ⇒ Boolean
40 41 42 |
# File 'lib/rbs/ast/members.rb', line 40 def instance? kind == :instance || kind == :singleton_instance end |
permalink #overload? ⇒ Boolean
48 49 50 |
# File 'lib/rbs/ast/members.rb', line 48 def overload? overload end |
permalink #singleton? ⇒ Boolean
44 45 46 |
# File 'lib/rbs/ast/members.rb', line 44 def singleton? kind == :singleton || kind == :singleton_instance end |
permalink #to_json(state = _ = nil) ⇒ Object
[View source]
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rbs/ast/members.rb', line 64 def to_json(state = _ = nil) { member: :method_definition, kind: kind, types: types, annotations: annotations, location: location, comment: comment, overload: overload }.to_json(state) end |
permalink #update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, overload: self.overload) ⇒ Object
[View source]
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rbs/ast/members.rb', line 52 def update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, overload: self.overload) self.class.new( name: name, kind: kind, types: types, annotations: annotations, location: location, comment: comment, overload: overload ) end |