Class: RBI::SigParam
- Inherits:
-
NodeWithComments
- Object
- Node
- NodeWithComments
- RBI::SigParam
- Extended by:
- T::Sig
- Defined in:
- lib/rbi/model.rb,
lib/rbi/printer.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from NodeWithComments
Attributes inherited from Node
Instance Method Summary collapse
- #==(other) ⇒ Object
- #accept_printer(v) ⇒ Object
- #comments_lines ⇒ Object
-
#initialize(name, type, loc: nil, comments: [], &block) ⇒ SigParam
constructor
A new instance of SigParam.
- #print_comment_leading_space(v, last:) ⇒ 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, type, loc: nil, comments: [], &block) ⇒ SigParam
Returns a new instance of SigParam.
1101 1102 1103 1104 1105 1106 |
# File 'lib/rbi/model.rb', line 1101 def initialize(name, type, loc: nil, comments: [], &block) super(loc: loc, comments: comments) @name = name @type = type block&.call(self) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
1090 1091 1092 |
# File 'lib/rbi/model.rb', line 1090 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
1090 1091 1092 |
# File 'lib/rbi/model.rb', line 1090 def type @type end |
Instance Method Details
#==(other) ⇒ Object
1109 1110 1111 |
# File 'lib/rbi/model.rb', line 1109 def ==(other) other.is_a?(SigParam) && name == other.name && type == other.type end |
#accept_printer(v) ⇒ Object
683 684 685 |
# File 'lib/rbi/printer.rb', line 683 def accept_printer(v) v.print("#{name}: #{type}") end |
#comments_lines ⇒ Object
696 697 698 |
# File 'lib/rbi/printer.rb', line 696 def comments_lines comments.flat_map { |comment| comment.text.lines.map(&:strip) } end |
#print_comment_leading_space(v, last:) ⇒ Object
688 689 690 691 692 693 |
# File 'lib/rbi/printer.rb', line 688 def print_comment_leading_space(v, last:) v.printn v.printt v.print(" " * (name.size + type.size + 3)) v.print(" ") unless last end |