Class: RBI::OptParam

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

Direct Known Subclasses

KwOptParam

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

#to_s

Methods inherited from NodeWithComments

#merge_with, #oneline?

Methods inherited from Node

#compatible_with?, #detach, #group_kind, #merge_with, #oneline?, #parent_conflict_tree, #parent_scope, #print, #replace, #string

Constructor Details

#initialize(name, value, loc: nil, comments: []) ⇒ OptParam

Returns a new instance of OptParam.



459
460
461
462
# File 'lib/rbi/model.rb', line 459

def initialize(name, value, loc: nil, comments: [])
  super(name, loc: loc, comments: comments)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



456
457
458
# File 'lib/rbi/model.rb', line 456

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



465
466
467
468
469
470
# File 'lib/rbi/model.rb', line 465

def ==(other)
  return false unless other.instance_of?(OptParam)
  other = T.cast(other, OptParam)
  return false unless name == other.name
  value == other.value
end

#accept_printer(v) ⇒ Object



388
389
390
# File 'lib/rbi/printer.rb', line 388

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


393
394
395
396
# File 'lib/rbi/printer.rb', line 393

def print_comment_leading_space(v)
  super
  v.print(" " * (value.size + 3))
end