Class: SyntaxTree::Reflection::Type::TupleType
- Inherits:
-
Object
- Object
- SyntaxTree::Reflection::Type::TupleType
- Defined in:
- lib/syntax_tree/reflection.rb
Overview
Represents a tuple type that holds a number of types in order.
Instance Attribute Summary collapse
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
- #===(value) ⇒ Object
-
#initialize(types) ⇒ TupleType
constructor
A new instance of TupleType.
- #inspect ⇒ Object
Constructor Details
#initialize(types) ⇒ TupleType
Returns a new instance of TupleType.
34 35 36 |
# File 'lib/syntax_tree/reflection.rb', line 34 def initialize(types) @types = types end |
Instance Attribute Details
#types ⇒ Object (readonly)
Returns the value of attribute types.
32 33 34 |
# File 'lib/syntax_tree/reflection.rb', line 32 def types @types end |
Instance Method Details
#===(value) ⇒ Object
38 39 40 41 |
# File 'lib/syntax_tree/reflection.rb', line 38 def ===(value) value.is_a?(Array) && value.length == types.length && value.zip(types).all? { |item, type| type === item } end |
#inspect ⇒ Object
43 44 45 |
# File 'lib/syntax_tree/reflection.rb', line 43 def inspect "[#{types.map(&:inspect).join(", ")}]" end |