Class: RBI::OptParam

Inherits:
Param show all
Defined in:
lib/rbi/model.rb

Instance Attribute Summary collapse

Attributes inherited from NodeWithComments

#comments

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

Methods inherited from Param

#compatible_with?

Methods inherited from NodeWithComments

#annotations, #comments?, #merge_with, #version_requirements

Methods inherited from Node

#compatible_with?, #detach, #merge_with, #parent_conflict_tree, #parent_scope, #print, #rbs_print, #rbs_string, #replace, #satisfies_version?, #string

Constructor Details

#initialize(name, value, loc: nil, comments: nil, &block) ⇒ OptParam

: (String name, String value, ?loc: Loc?, ?comments: Array?) ?{ (OptParam node) -> void } -> void



661
662
663
664
665
666
# File 'lib/rbi/model.rb', line 661

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

Instance Attribute Details

#nameObject (readonly)

: String



655
656
657
# File 'lib/rbi/model.rb', line 655

def name
  @name
end

#valueObject (readonly)

: String



658
659
660
# File 'lib/rbi/model.rb', line 658

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object

: (Object? other) -> bool



681
682
683
# File 'lib/rbi/model.rb', line 681

def ==(other)
  OptParam === other && (name == other.name)
end

#anonymous?Boolean

: -> bool

Returns:

  • (Boolean)


676
677
678
# File 'lib/rbi/model.rb', line 676

def anonymous?
  false
end

#to_sObject

: -> String



670
671
672
# File 'lib/rbi/model.rb', line 670

def to_s
  "#{name} = #{value}"
end