Class: RBS::Definition::Method::TypeDef
- Inherits:
-
Object
- Object
- RBS::Definition::Method::TypeDef
- Defined in:
- lib/rbs/definition.rb
Instance Attribute Summary collapse
-
#annotations ⇒ Object
readonly
Returns the value of attribute annotations.
-
#defined_in ⇒ Object
readonly
Returns the value of attribute defined_in.
-
#implemented_in ⇒ Object
readonly
Returns the value of attribute implemented_in.
-
#member ⇒ Object
readonly
Returns the value of attribute member.
-
#member_annotations ⇒ Object
readonly
Returns the value of attribute member_annotations.
-
#overload_annotations ⇒ Object
readonly
Returns the value of attribute overload_annotations.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #comment ⇒ Object
- #each_annotation(&block) ⇒ Object
- #hash ⇒ Object
-
#initialize(type:, member:, defined_in:, implemented_in:, overload_annotations: []) ⇒ TypeDef
constructor
A new instance of TypeDef.
- #overload? ⇒ Boolean
- #update(type: self.type, member: self.member, defined_in: self.defined_in, implemented_in: self.implemented_in) ⇒ Object
Constructor Details
#initialize(type:, member:, defined_in:, implemented_in:, overload_annotations: []) ⇒ TypeDef
40 41 42 43 44 45 46 47 48 |
# File 'lib/rbs/definition.rb', line 40 def initialize(type:, member:, defined_in:, implemented_in:, overload_annotations: []) @type = type @member = member @defined_in = defined_in @implemented_in = implemented_in @member_annotations = [] @overload_annotations = [] @annotations = [] end |
Instance Attribute Details
#annotations ⇒ Object (readonly)
Returns the value of attribute annotations.
38 39 40 |
# File 'lib/rbs/definition.rb', line 38 def annotations @annotations end |
#defined_in ⇒ Object (readonly)
Returns the value of attribute defined_in.
34 35 36 |
# File 'lib/rbs/definition.rb', line 34 def defined_in @defined_in end |
#implemented_in ⇒ Object (readonly)
Returns the value of attribute implemented_in.
35 36 37 |
# File 'lib/rbs/definition.rb', line 35 def implemented_in @implemented_in end |
#member ⇒ Object (readonly)
Returns the value of attribute member.
33 34 35 |
# File 'lib/rbs/definition.rb', line 33 def member @member end |
#member_annotations ⇒ Object (readonly)
Returns the value of attribute member_annotations.
36 37 38 |
# File 'lib/rbs/definition.rb', line 36 def member_annotations @member_annotations end |
#overload_annotations ⇒ Object (readonly)
Returns the value of attribute overload_annotations.
37 38 39 |
# File 'lib/rbs/definition.rb', line 37 def overload_annotations @overload_annotations end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
32 33 34 |
# File 'lib/rbs/definition.rb', line 32 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
50 51 52 53 54 55 56 |
# File 'lib/rbs/definition.rb', line 50 def ==(other) other.is_a?(TypeDef) && other.type == type && other.member == member && other.defined_in == defined_in && other.implemented_in == implemented_in end |
#comment ⇒ Object
64 65 66 |
# File 'lib/rbs/definition.rb', line 64 def comment member.comment end |
#each_annotation(&block) ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/rbs/definition.rb', line 84 def each_annotation(&block) if block member_annotations.each(&block) overload_annotations.each(&block) else enum_for :each_annotation end end |
#hash ⇒ Object
60 61 62 |
# File 'lib/rbs/definition.rb', line 60 def hash self.class.hash ^ type.hash ^ member.hash ^ defined_in.hash ^ implemented_in.hash end |
#overload? ⇒ Boolean
75 76 77 78 79 80 81 82 |
# File 'lib/rbs/definition.rb', line 75 def overload? case mem = member when AST::Members::MethodDefinition mem.overloading? else false end end |
#update(type: self.type, member: self.member, defined_in: self.defined_in, implemented_in: self.implemented_in) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/rbs/definition.rb', line 68 def update(type: self.type, member: self.member, defined_in: self.defined_in, implemented_in: self.implemented_in) TypeDef.new(type: type, member: member, defined_in: defined_in, implemented_in: implemented_in).tap do |type_def| type_def.overload_annotations.replace(self.overload_annotations) type_def.member_annotations.replace(self.member_annotations) end end |