Class: RBS::AST::Members::MethodDefinition
- Includes:
- _ToJson, _HashEqual
- Defined in:
- lib/rbs/ast/members.rb,
sig/members.rbs
Defined Under Namespace
Classes: Overload
Instance Attribute Summary collapse
-
#annotations ⇒ Array[Annotation]
readonly
Returns the value of attribute annotations.
-
#comment ⇒ Comment?
readonly
Returns the value of attribute comment.
-
#kind ⇒ kind
readonly
Returns the value of attribute kind.
-
#location ⇒ loc?
readonly
Returns the value of attribute location.
-
#name ⇒ Symbol
readonly
Returns the value of attribute name.
-
#overloading ⇒ Boolean
readonly
Returns the value of attribute overloading.
-
#overloads ⇒ Array[Overload]
readonly
Returns the value of attribute overloads.
-
#visibility ⇒ visibility?
readonly
Returns the value of attribute visibility.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name:, kind:, overloads:, annotations:, location:, comment:, overloading:, visibility:) ⇒ MethodDefinition
constructor
A new instance of MethodDefinition.
-
#instance? ⇒ Boolean
Returns true if the
defis to define instance method. -
#overloading? ⇒ Boolean
Returns true if the
defis overloading (== with...). -
#singleton? ⇒ Boolean
Returns true if the
defis to define singleton method. - #to_json(state = nil) ⇒ Object
- #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) ⇒ MethodDefinition
Constructor Details
#initialize(name:, kind:, overloads:, annotations:, location:, comment:, overloading:, visibility:) ⇒ MethodDefinition
Returns a new instance of MethodDefinition.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rbs/ast/members.rb', line 55 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
#annotations ⇒ Array[Annotation] (readonly)
Returns the value of attribute annotations.
49 50 51 |
# File 'lib/rbs/ast/members.rb', line 49 def annotations @annotations end |
#comment ⇒ Comment? (readonly)
Returns the value of attribute comment.
51 52 53 |
# File 'lib/rbs/ast/members.rb', line 51 def comment @comment end |
#kind ⇒ kind (readonly)
Returns the value of attribute kind.
47 48 49 |
# File 'lib/rbs/ast/members.rb', line 47 def kind @kind end |
#location ⇒ loc? (readonly)
Returns the value of attribute location.
50 51 52 |
# File 'lib/rbs/ast/members.rb', line 50 def location @location end |
#name ⇒ Symbol (readonly)
Returns the value of attribute name.
46 47 48 |
# File 'lib/rbs/ast/members.rb', line 46 def name @name end |
#overloading ⇒ Boolean (readonly)
Returns the value of attribute overloading.
52 53 54 |
# File 'lib/rbs/ast/members.rb', line 52 def overloading @overloading end |
#overloads ⇒ Array[Overload] (readonly)
Returns the value of attribute overloads.
48 49 50 |
# File 'lib/rbs/ast/members.rb', line 48 def overloads @overloads end |
#visibility ⇒ visibility? (readonly)
Returns the value of attribute visibility.
53 54 55 |
# File 'lib/rbs/ast/members.rb', line 53 def visibility @visibility end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
66 67 68 69 70 71 72 73 |
# File 'lib/rbs/ast/members.rb', line 66 def ==(other) other.is_a?(MethodDefinition) && other.name == name && other.kind == kind && other.overloads == overloads && other.overloading? == overloading? && other.visibility == visibility end |
#hash ⇒ Object
77 78 79 |
# File 'lib/rbs/ast/members.rb', line 77 def hash name.hash ^ kind.hash ^ overloads.hash ^ overloading?.hash ^ visibility.hash end |
#instance? ⇒ Boolean
Returns true if the def is to define instance method
68 69 70 |
# File 'sig/members.rbs', line 68 def instance? kind == :instance || kind == :singleton_instance end |
#overloading? ⇒ Boolean
Returns true if the def is overloading (== with ...)
75 76 77 |
# File 'sig/members.rbs', line 75 def overloading? overloading end |
#singleton? ⇒ Boolean
Returns true if the def is to define singleton method
71 72 73 |
# File 'sig/members.rbs', line 71 def singleton? kind == :singleton || kind == :singleton_instance end |
#to_json(state = nil) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/rbs/ast/members.rb', line 106 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) ⇒ MethodDefinition
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/rbs/ast/members.rb', line 93 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 |