Class: Tapioca::RBI::Method
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/rbi/model.rb,
lib/tapioca/rbi/printer.rb
Overview
Methods and args
Instance Attribute Summary collapse
-
#is_singleton ⇒ Object
Returns the value of attribute is_singleton.
-
#name ⇒ Object
Returns the value of attribute name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#sigs ⇒ Object
Returns the value of attribute sigs.
-
#visibility ⇒ Object
Returns the value of attribute visibility.
Attributes inherited from Node
Instance Method Summary collapse
- #<<(param) ⇒ Object
- #accept_printer(v) ⇒ Object
-
#initialize(name, params: [], is_singleton: false, visibility: Visibility::Public, sigs: []) ⇒ Method
constructor
A new instance of Method.
- #oneline? ⇒ Boolean
Methods inherited from Node
#detach, #group_kind, #print, #string
Constructor Details
#initialize(name, params: [], is_singleton: false, visibility: Visibility::Public, sigs: []) ⇒ Method
Returns a new instance of Method.
145 146 147 148 149 150 151 152 |
# File 'lib/tapioca/rbi/model.rb', line 145 def initialize(name, params: [], is_singleton: false, visibility: Visibility::Public, sigs: []) super() @name = name @params = params @is_singleton = is_singleton @visibility = visibility @sigs = sigs end |
Instance Attribute Details
#is_singleton ⇒ Object
Returns the value of attribute is_singleton.
128 129 130 |
# File 'lib/tapioca/rbi/model.rb', line 128 def is_singleton @is_singleton end |
#name ⇒ Object
Returns the value of attribute name.
122 123 124 |
# File 'lib/tapioca/rbi/model.rb', line 122 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
125 126 127 |
# File 'lib/tapioca/rbi/model.rb', line 125 def params @params end |
#sigs ⇒ Object
Returns the value of attribute sigs.
134 135 136 |
# File 'lib/tapioca/rbi/model.rb', line 134 def sigs @sigs end |
#visibility ⇒ Object
Returns the value of attribute visibility.
131 132 133 |
# File 'lib/tapioca/rbi/model.rb', line 131 def visibility @visibility end |
Instance Method Details
#<<(param) ⇒ Object
155 156 157 |
# File 'lib/tapioca/rbi/model.rb', line 155 def <<(param) @params << param end |
#accept_printer(v) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/tapioca/rbi/printer.rb', line 166 def accept_printer(v) previous_node = v.previous_node v.printn if previous_node && (!previous_node.oneline? || !oneline?) v.visit_all(sigs) v.printt unless v.in_visibility_group || visibility == Visibility::Public v.print(visibility.visibility.to_s) v.print(" ") end v.print("def ") v.print("self.") if is_singleton v.print(name) unless params.empty? v.print("(") params.each_with_index do |param, index| v.print(", ") if index > 0 v.visit(param) end v.print(")") end v.print("; end") v.printn end |
#oneline? ⇒ Boolean
192 193 194 |
# File 'lib/tapioca/rbi/printer.rb', line 192 def oneline? sigs.empty? end |