Class: RBS::AST::Declarations::ModuleTypeParams
- Inherits:
-
Object
- Object
- RBS::AST::Declarations::ModuleTypeParams
- Defined in:
- lib/rbs/ast/declarations.rb
Defined Under Namespace
Classes: TypeParam
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #[](name) ⇒ Object
- #add(param) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #hash ⇒ Object
-
#initialize ⇒ ModuleTypeParams
constructor
A new instance of ModuleTypeParams.
- #rename_to(names) ⇒ Object
- #size ⇒ Object
- #skip_validation?(name) ⇒ Boolean
- #to_json(*a) ⇒ Object
- #variance(name) ⇒ Object
Constructor Details
#initialize ⇒ ModuleTypeParams
Returns a new instance of ModuleTypeParams.
9 10 11 |
# File 'lib/rbs/ast/declarations.rb', line 9 def initialize() @params = [] end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/rbs/ast/declarations.rb', line 5 def params @params end |
Class Method Details
.empty ⇒ Object
42 43 44 |
# File 'lib/rbs/ast/declarations.rb', line 42 def self.empty new end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
18 19 20 |
# File 'lib/rbs/ast/declarations.rb', line 18 def ==(other) other.is_a?(ModuleTypeParams) && other.params == params end |
#[](name) ⇒ Object
28 29 30 |
# File 'lib/rbs/ast/declarations.rb', line 28 def [](name) params.find {|p| p.name == name } end |
#add(param) ⇒ Object
13 14 15 16 |
# File 'lib/rbs/ast/declarations.rb', line 13 def add(param) params << param self end |
#each(&block) ⇒ Object
38 39 40 |
# File 'lib/rbs/ast/declarations.rb', line 38 def each(&block) params.each(&block) end |
#empty? ⇒ Boolean
54 55 56 |
# File 'lib/rbs/ast/declarations.rb', line 54 def empty? params.empty? end |
#hash ⇒ Object
24 25 26 |
# File 'lib/rbs/ast/declarations.rb', line 24 def hash params.hash end |
#rename_to(names) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/rbs/ast/declarations.rb', line 62 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)) end end end |
#size ⇒ Object
58 59 60 |
# File 'lib/rbs/ast/declarations.rb', line 58 def size params.size end |
#skip_validation?(name) ⇒ Boolean
50 51 52 |
# File 'lib/rbs/ast/declarations.rb', line 50 def skip_validation?(name) self[name].skip_validation end |
#to_json(*a) ⇒ Object
32 33 34 35 36 |
# File 'lib/rbs/ast/declarations.rb', line 32 def to_json(*a) { params: params }.to_json(*a) end |
#variance(name) ⇒ Object
46 47 48 |
# File 'lib/rbs/ast/declarations.rb', line 46 def variance(name) self[name].variance end |