Class: RBI::Param Abstract

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

Overview

This class is abstract.

Instance Attribute Summary collapse

Attributes inherited from NodeWithComments

#comments

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

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, loc: nil, comments: nil) ⇒ Param

: (String name, ?loc: Loc?, ?comments: Array?) -> void



606
607
608
609
610
# File 'lib/rbi/model.rb', line 606

def initialize(name, loc: nil, comments: nil)
  super(loc: loc, comments: comments)
  @name = name.to_s #: String
  @anonymous = name.start_with?("_") #: bool
end

Instance Attribute Details

#nameObject (readonly)

: String



603
604
605
# File 'lib/rbi/model.rb', line 603

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object

: (Object? other) -> bool



624
625
626
627
# File 'lib/rbi/model.rb', line 624

def ==(other)
  self.class === other &&
    (name == other.name || anonymous? || other.anonymous?)
end

#anonymous?Boolean

: -> bool

Returns:

  • (Boolean)


619
620
621
# File 'lib/rbi/model.rb', line 619

def anonymous?
  @anonymous
end

#to_sObject

: -> String



614
615
616
# File 'lib/rbi/model.rb', line 614

def to_s
  name
end