Class: RBI::KwOptParam

Inherits:
Param show all
Extended by:
T::Sig
Defined in:
lib/rbi/model.rb,
lib/rbi/printer.rb

Instance Attribute Summary collapse

Attributes inherited from Param

#name

Attributes inherited from NodeWithComments

#comments

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

Methods inherited from Param

#comments_lines

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, value, loc: nil, comments: [], &block) ⇒ KwOptParam

Returns a new instance of KwOptParam.



689
690
691
692
693
# File 'lib/rbi/model.rb', line 689

def initialize(name, value, loc: nil, comments: [], &block)
  super(name, loc: loc, comments: comments)
  @value = value
  block&.call(self)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



678
679
680
# File 'lib/rbi/model.rb', line 678

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



701
702
703
# File 'lib/rbi/model.rb', line 701

def ==(other)
  KwOptParam === other && name == other.name && value == other.value
end

#accept_printer(v) ⇒ Object



483
484
485
# File 'lib/rbi/printer.rb', line 483

def accept_printer(v)
  v.print("#{name}: #{value}")
end


488
489
490
491
# File 'lib/rbi/printer.rb', line 488

def print_comment_leading_space(v, last:)
  super
  v.print(" " * (value.size + 2))
end

#to_sObject



696
697
698
# File 'lib/rbi/model.rb', line 696

def to_s
  "#{name}:"
end