Class: RBS::Types::Tuple
- Inherits:
-
Object
- Object
- RBS::Types::Tuple
- Defined in:
- lib/rbs/types.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #each_type(&block) ⇒ Object
- #free_variables(set = Set.new) ⇒ Object
- #hash ⇒ Object
-
#initialize(types:, location:) ⇒ Tuple
constructor
A new instance of Tuple.
- #map_type_name(&block) ⇒ Object
- #sub(s) ⇒ Object
- #to_json(state = _ = nil) ⇒ Object
- #to_s(level = 0) ⇒ Object
Constructor Details
#initialize(types:, location:) ⇒ Tuple
Returns a new instance of Tuple.
328 329 330 331 |
# File 'lib/rbs/types.rb', line 328 def initialize(types:, location:) @types = types @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
326 327 328 |
# File 'lib/rbs/types.rb', line 326 def location @location end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
325 326 327 |
# File 'lib/rbs/types.rb', line 325 def types @types end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
333 334 335 |
# File 'lib/rbs/types.rb', line 333 def ==(other) other.is_a?(Tuple) && other.types == types end |
#each_type(&block) ⇒ Object
368 369 370 371 372 373 374 |
# File 'lib/rbs/types.rb', line 368 def each_type(&block) if block types.each(&block) else enum_for :each_type end end |
#free_variables(set = Set.new) ⇒ Object
343 344 345 346 347 348 349 |
# File 'lib/rbs/types.rb', line 343 def free_variables(set = Set.new) set.tap do types.each do |type| type.free_variables set end end end |
#hash ⇒ Object
339 340 341 |
# File 'lib/rbs/types.rb', line 339 def hash self.class.hash ^ types.hash end |
#map_type_name(&block) ⇒ Object
376 377 378 379 380 381 |
# File 'lib/rbs/types.rb', line 376 def map_type_name(&block) Tuple.new( types: types.map {|type| type.map_type_name(&block) }, location: location ) end |
#sub(s) ⇒ Object
355 356 357 358 |
# File 'lib/rbs/types.rb', line 355 def sub(s) self.class.new(types: types.map {|ty| ty.sub(s) }, location: location) end |
#to_json(state = _ = nil) ⇒ Object
351 352 353 |
# File 'lib/rbs/types.rb', line 351 def to_json(state = _ = nil) { class: :tuple, types: types, location: location }.to_json(state) end |
#to_s(level = 0) ⇒ Object
360 361 362 363 364 365 366 |
# File 'lib/rbs/types.rb', line 360 def to_s(level = 0) if types.empty? "[ ]" else "[ #{types.join(", ")} ]" end end |