Class: RBI::Param Abstract

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

Overview

This class is abstract.

Instance Attribute Summary

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

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

Constructor Details

#initialize(loc: nil, comments: nil) ⇒ Param

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



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

def initialize(loc: nil, comments: nil)
  super(loc: loc, comments: comments)
end

Instance Method Details

#anonymous?Boolean

This method is abstract.

: -> bool

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


617
618
619
# File 'lib/rbi/model.rb', line 617

def anonymous?
  raise NotImplementedError, "Abstract method called"
end

#compatible_with?(other) ⇒ Boolean

: (Node? other) -> bool

Returns:

  • (Boolean)


543
544
545
# File 'lib/rbi/rewriters/merge_trees.rb', line 543

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

#nameObject

: -> String?



608
609
610
611
612
613
# File 'lib/rbi/model.rb', line 608

def name
  case self
  when ReqParam, OptParam, KwParam, KwOptParam, RestParam, KwRestParam, BlockParam
    name
  end
end