Class: RBS::Definition::Method
- Inherits:
-
Object
- Object
- RBS::Definition::Method
- Defined in:
- lib/rbs/definition.rb
Defined Under Namespace
Classes: TypeDef
Instance Attribute Summary collapse
-
#accessibility ⇒ Object
readonly
Returns the value of attribute accessibility.
-
#defs ⇒ Object
readonly
Returns the value of attribute defs.
-
#extra_annotations ⇒ Object
readonly
Returns the value of attribute extra_annotations.
-
#super_method ⇒ Object
readonly
Returns the value of attribute super_method.
Instance Method Summary collapse
- #annotations ⇒ Object
- #comments ⇒ Object
- #defined_in ⇒ Object
- #implemented_in ⇒ Object
-
#initialize(super_method:, defs:, accessibility:, annotations: []) ⇒ Method
constructor
A new instance of Method.
- #map_method_type(&block) ⇒ Object
- #map_type(&block) ⇒ Object
- #members ⇒ Object
- #method_types ⇒ Object
- #private? ⇒ Boolean
- #public? ⇒ Boolean
- #sub(s) ⇒ Object
Constructor Details
#initialize(super_method:, defs:, accessibility:, annotations: []) ⇒ Method
Returns a new instance of Method.
64 65 66 67 68 69 |
# File 'lib/rbs/definition.rb', line 64 def initialize(super_method:, defs:, accessibility:, annotations: []) @super_method = super_method @defs = defs @accessibility = accessibility @extra_annotations = annotations end |
Instance Attribute Details
#accessibility ⇒ Object (readonly)
Returns the value of attribute accessibility.
61 62 63 |
# File 'lib/rbs/definition.rb', line 61 def accessibility @accessibility end |
#defs ⇒ Object (readonly)
Returns the value of attribute defs.
60 61 62 |
# File 'lib/rbs/definition.rb', line 60 def defs @defs end |
#extra_annotations ⇒ Object (readonly)
Returns the value of attribute extra_annotations.
62 63 64 |
# File 'lib/rbs/definition.rb', line 62 def extra_annotations @extra_annotations end |
#super_method ⇒ Object (readonly)
Returns the value of attribute super_method.
59 60 61 |
# File 'lib/rbs/definition.rb', line 59 def super_method @super_method end |
Instance Method Details
#annotations ⇒ Object
93 94 95 |
# File 'lib/rbs/definition.rb', line 93 def annotations @annotations ||= @extra_annotations + defs.flat_map(&:annotations) end |
#comments ⇒ Object
89 90 91 |
# File 'lib/rbs/definition.rb', line 89 def comments @comments ||= _ = defs.map(&:comment).compact end |
#defined_in ⇒ Object
71 72 73 74 75 76 |
# File 'lib/rbs/definition.rb', line 71 def defined_in @defined_in ||= begin last_def = defs.last or raise last_def.defined_in end end |
#implemented_in ⇒ Object
78 79 80 81 82 83 |
# File 'lib/rbs/definition.rb', line 78 def implemented_in @implemented_in ||= begin last_def = defs.last or raise last_def.implemented_in end end |
#map_method_type(&block) ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/rbs/definition.rb', line 125 def map_method_type(&block) self.class.new( super_method: super_method, defs: defs.map {|defn| defn.update(type: yield(defn.type)) }, accessibility: @accessibility ) end |
#map_type(&block) ⇒ Object
117 118 119 120 121 122 123 |
# File 'lib/rbs/definition.rb', line 117 def map_type(&block) self.class.new( super_method: super_method&.map_type(&block), defs: defs.map {|defn| defn.update(type: defn.type.map_type(&block)) }, accessibility: @accessibility ) end |
#members ⇒ Object
97 98 99 |
# File 'lib/rbs/definition.rb', line 97 def members @members ||= defs.map(&:member).uniq end |
#method_types ⇒ Object
85 86 87 |
# File 'lib/rbs/definition.rb', line 85 def method_types @method_types ||= defs.map(&:type) end |
#private? ⇒ Boolean
105 106 107 |
# File 'lib/rbs/definition.rb', line 105 def private? @accessibility == :private end |
#public? ⇒ Boolean
101 102 103 |
# File 'lib/rbs/definition.rb', line 101 def public? @accessibility == :public end |
#sub(s) ⇒ Object
109 110 111 112 113 114 115 |
# File 'lib/rbs/definition.rb', line 109 def sub(s) self.class.new( super_method: super_method&.sub(s), defs: defs.map {|defn| defn.update(type: defn.type.sub(s)) }, accessibility: @accessibility ) end |