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.
20 21 22 |
# File 'lib/rbs/ast/declarations.rb', line 20 def initialize() @params = [] end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/rbs/ast/declarations.rb', line 8 def params @params end |
Class Method Details
.empty ⇒ Object
53 54 55 |
# File 'lib/rbs/ast/declarations.rb', line 53 def self.empty new end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
29 30 31 |
# File 'lib/rbs/ast/declarations.rb', line 29 def ==(other) other.is_a?(ModuleTypeParams) && other.params == params end |
#[](name) ⇒ Object
39 40 41 |
# File 'lib/rbs/ast/declarations.rb', line 39 def [](name) params.find {|p| p.name == name } end |
#add(param) ⇒ Object
24 25 26 27 |
# File 'lib/rbs/ast/declarations.rb', line 24 def add(param) params << param self end |
#each(&block) ⇒ Object
49 50 51 |
# File 'lib/rbs/ast/declarations.rb', line 49 def each(&block) params.each(&block) end |
#empty? ⇒ Boolean
65 66 67 |
# File 'lib/rbs/ast/declarations.rb', line 65 def empty? params.empty? end |
#hash ⇒ Object
35 36 37 |
# File 'lib/rbs/ast/declarations.rb', line 35 def hash params.hash end |
#rename_to(names) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/rbs/ast/declarations.rb', line 73 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
69 70 71 |
# File 'lib/rbs/ast/declarations.rb', line 69 def size params.size end |
#skip_validation?(name) ⇒ Boolean
61 62 63 |
# File 'lib/rbs/ast/declarations.rb', line 61 def skip_validation?(name) self[name].skip_validation end |
#to_json(*a) ⇒ Object
43 44 45 46 47 |
# File 'lib/rbs/ast/declarations.rb', line 43 def to_json(*a) { params: params }.to_json(*a) end |
#variance(name) ⇒ Object
57 58 59 |
# File 'lib/rbs/ast/declarations.rb', line 57 def variance(name) self[name].variance end |