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.
17 18 19 |
# File 'lib/rbs/ast/declarations.rb', line 17 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
50 51 52 |
# File 'lib/rbs/ast/declarations.rb', line 50 def self.empty new end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
26 27 28 |
# File 'lib/rbs/ast/declarations.rb', line 26 def ==(other) other.is_a?(ModuleTypeParams) && other.params == params end |
#[](name) ⇒ Object
36 37 38 |
# File 'lib/rbs/ast/declarations.rb', line 36 def [](name) params.find {|p| p.name == name } end |
#add(param) ⇒ Object
21 22 23 24 |
# File 'lib/rbs/ast/declarations.rb', line 21 def add(param) params << param self end |
#each(&block) ⇒ Object
46 47 48 |
# File 'lib/rbs/ast/declarations.rb', line 46 def each(&block) params.each(&block) end |
#empty? ⇒ Boolean
62 63 64 |
# File 'lib/rbs/ast/declarations.rb', line 62 def empty? params.empty? end |
#hash ⇒ Object
32 33 34 |
# File 'lib/rbs/ast/declarations.rb', line 32 def hash params.hash end |
#rename_to(names) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/rbs/ast/declarations.rb', line 70 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
66 67 68 |
# File 'lib/rbs/ast/declarations.rb', line 66 def size params.size end |
#skip_validation?(name) ⇒ Boolean
58 59 60 |
# File 'lib/rbs/ast/declarations.rb', line 58 def skip_validation?(name) self[name].skip_validation end |
#to_json(*a) ⇒ Object
40 41 42 43 44 |
# File 'lib/rbs/ast/declarations.rb', line 40 def to_json(*a) { params: params }.to_json(*a) end |
#variance(name) ⇒ Object
54 55 56 |
# File 'lib/rbs/ast/declarations.rb', line 54 def variance(name) self[name].variance end |