Class: RBS::AST::Declarations::ModuleTypeParams
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rbs/ast/declarations.rb |
Constant Summary
-
TypeParam =
# File 'lib/rbs/ast/declarations.rb', line 10_ = Struct.new(:name, :variance, :skip_validation, :location, keyword_init: true) do # @implements TypeParam def to_json(state = _ = nil) { name: name, variance: variance, skip_validation: skip_validation, }.to_json(state) end def ==(other) other.is_a?(TypeParam) && other.name == name && other.variance == variance && other.skip_validation == skip_validation end alias eql? == def hash self.class.hash ^ name.hash ^ variance.hash ^ skip_validation.hash end end
Class Method Summary
- .empty
- .new ⇒ ModuleTypeParams constructor
Instance Attribute Summary
- #empty? ⇒ Boolean readonly
- #params readonly
Instance Method Summary
Constructor Details
.new ⇒ ModuleTypeParams
# 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 ]#[](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 ]#eql?(other)
[ 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
# 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