Class: Tapioca::RBI::TStructField
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/tapioca/rbi/model.rb,
lib/tapioca/rbi/printer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Node
Instance Method Summary collapse
- #accept_printer(v) ⇒ Object
-
#initialize(name, type, default: nil) ⇒ TStructField
constructor
A new instance of TStructField.
Methods inherited from Node
#detach, #group_kind, #oneline?, #print, #string
Constructor Details
#initialize(name, type, default: nil) ⇒ TStructField
Returns a new instance of TStructField.
334 335 336 337 338 339 |
# File 'lib/tapioca/rbi/model.rb', line 334 def initialize(name, type, default: nil) super() @name = name @type = type @default = default end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
325 326 327 |
# File 'lib/tapioca/rbi/model.rb', line 325 def default @default end |
#name ⇒ Object
Returns the value of attribute name.
322 323 324 |
# File 'lib/tapioca/rbi/model.rb', line 322 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
322 323 324 |
# File 'lib/tapioca/rbi/model.rb', line 322 def type @type end |
Instance Method Details
#accept_printer(v) ⇒ Object
333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/tapioca/rbi/printer.rb', line 333 def accept_printer(v) case self when TStructProp v.printt("prop") when TStructConst v.printt("const") end v.print(" :#{name}, #{type}") default = self.default v.print(", default: #{default}") if default v.printn end |