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.
-
#super_method ⇒ Object
readonly
Returns the value of attribute super_method.
Instance Method Summary collapse
- #annotations ⇒ Object
- #attributes ⇒ Object deprecated Deprecated.
- #comments ⇒ Object
- #defined_in ⇒ Object
- #implemented_in ⇒ Object
-
#initialize(super_method:, defs:, accessibility:) ⇒ Method
constructor
A new instance of Method.
- #map_method_type(&block) ⇒ Object
- #map_type(&block) ⇒ Object
- #method_types ⇒ Object
- #private? ⇒ Boolean
- #public? ⇒ Boolean
- #sub(s) ⇒ Object
Constructor Details
#initialize(super_method:, defs:, accessibility:) ⇒ Method
Returns a new instance of Method.
54 55 56 57 58 |
# File 'lib/rbs/definition.rb', line 54 def initialize(super_method:, defs:, accessibility:) @super_method = super_method @defs = defs @accessibility = accessibility end |
Instance Attribute Details
#accessibility ⇒ Object (readonly)
Returns the value of attribute accessibility.
52 53 54 |
# File 'lib/rbs/definition.rb', line 52 def accessibility @accessibility end |
#defs ⇒ Object (readonly)
Returns the value of attribute defs.
51 52 53 |
# File 'lib/rbs/definition.rb', line 51 def defs @defs end |
#super_method ⇒ Object (readonly)
Returns the value of attribute super_method.
50 51 52 |
# File 'lib/rbs/definition.rb', line 50 def super_method @super_method end |
Instance Method Details
#annotations ⇒ Object
76 77 78 |
# File 'lib/rbs/definition.rb', line 76 def annotations @annotations ||= defs.flat_map(&:annotations) end |
#attributes ⇒ Object
Deprecated.
81 82 83 |
# File 'lib/rbs/definition.rb', line 81 def attributes [] end |
#comments ⇒ Object
72 73 74 |
# File 'lib/rbs/definition.rb', line 72 def comments @comments ||= defs.map(&:comment).compact end |
#defined_in ⇒ Object
60 61 62 |
# File 'lib/rbs/definition.rb', line 60 def defined_in @defined_in ||= defs.last.defined_in end |
#implemented_in ⇒ Object
64 65 66 |
# File 'lib/rbs/definition.rb', line 64 def implemented_in @implemented_in ||= defs.last.implemented_in end |
#map_method_type(&block) ⇒ Object
109 110 111 112 113 114 115 |
# File 'lib/rbs/definition.rb', line 109 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
101 102 103 104 105 106 107 |
# File 'lib/rbs/definition.rb', line 101 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 |
#method_types ⇒ Object
68 69 70 |
# File 'lib/rbs/definition.rb', line 68 def method_types @method_types ||= defs.map(&:type) end |
#private? ⇒ Boolean
89 90 91 |
# File 'lib/rbs/definition.rb', line 89 def private? @accessibility == :private end |
#public? ⇒ Boolean
85 86 87 |
# File 'lib/rbs/definition.rb', line 85 def public? @accessibility == :public end |
#sub(s) ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/rbs/definition.rb', line 93 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 |