Class: RBI::Param
- Inherits:
-
NodeWithComments
- Object
- Node
- NodeWithComments
- RBI::Param
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/rbi/model.rb,
lib/rbi/printer.rb
Direct Known Subclasses
BlockParam, KwOptParam, KwParam, KwRestParam, OptParam, ReqParam, RestParam
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from NodeWithComments
Attributes inherited from Node
Instance Method Summary collapse
- #accept_printer(v) ⇒ Object
- #comments_lines ⇒ Object
-
#initialize(name, loc: nil, comments: []) ⇒ Param
constructor
A new instance of Param.
- #print_comment_leading_space(v, last:) ⇒ Object
- #to_s ⇒ Object
Methods inherited from NodeWithComments
#annotations, #merge_with, #oneline?
Methods inherited from Node
#compatible_with?, #detach, #group_kind, #merge_with, #oneline?, #parent_conflict_tree, #parent_scope, #print, #print_blank_line_before, #replace, #string
Constructor Details
#initialize(name, loc: nil, comments: []) ⇒ Param
Returns a new instance of Param.
560 561 562 563 |
# File 'lib/rbi/model.rb', line 560 def initialize(name, loc: nil, comments: []) super(loc: loc, comments: comments) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
551 552 553 |
# File 'lib/rbi/model.rb', line 551 def name @name end |
Instance Method Details
#accept_printer(v) ⇒ Object
416 417 418 |
# File 'lib/rbi/printer.rb', line 416 def accept_printer(v) v.print(name.to_s) end |
#comments_lines ⇒ Object
429 430 431 |
# File 'lib/rbi/printer.rb', line 429 def comments_lines comments.flat_map { |comment| comment.text.lines.map(&:strip) } end |
#print_comment_leading_space(v, last:) ⇒ Object
421 422 423 424 425 426 |
# File 'lib/rbi/printer.rb', line 421 def print_comment_leading_space(v, last:) v.printn v.printt v.print(" " * (name.size + 1)) v.print(" ") unless last end |
#to_s ⇒ Object
566 567 568 |
# File 'lib/rbi/model.rb', line 566 def to_s name end |