123456789_123456789_123456789_123456789_123456789_

Class: RBS::AST::Declarations::ModuleTypeParams

Relationships & Source Files
Inherits: Object
Defined in: lib/rbs/ast/declarations.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.newModuleTypeParams

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 35

def initialize()
  @params = []
end

Class Method Details

.empty

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 72

def self.empty
  new
end

Instance Attribute Details

#empty?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 86

def empty?
  params.empty?
end

#params (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 8

attr_reader :params

Instance Method Details

#==(other) Also known as: #eql?

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 44

def ==(other)
  other.is_a?(ModuleTypeParams) && other.params == params
end

#[](name)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 54

def [](name)
  params.find {|p| p.name == name }
end

#add(param)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 39

def add(param)
  params << param
  self
end

#each(&block)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 64

def each(&block)
  if block
    params.each(&block)
  else
    params.each
  end
end

#eql?(other)

Alias for #==.

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 48

alias eql? ==

#hash

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 50

def hash
  params.hash
end

#rename_to(names)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 94

def rename_to(names)
  ModuleTypeParams.new().tap do |params|
    names.each.with_index do |new_name, index|
      param = self.params[index]
      params.add(TypeParam.new(name: new_name, variance: param.variance, skip_validation: param.skip_validation, location: param.location))
    end
  end
end

#size

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 90

def size
  params.size
end

#skip_validation?(name) ⇒ Boolean

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 81

def skip_validation?(name)
  var = self[name] or raise
  var.skip_validation
end

#to_json(state = _ = nil)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 58

def to_json(state = _ = nil)
  {
    params: params
  }.to_json(state)
end

#variance(name)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 76

def variance(name)
  var = self[name] or raise
  var.variance
end