Class: Literal::Tuple::Generic
- Inherits:
-
Object
- Object
- Literal::Tuple::Generic
- Includes:
- Literal::Type
- Defined in:
- lib/literal/tuple.rb
Instance Attribute Summary collapse
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
- #===(other) ⇒ Object
- #>=(other) ⇒ Object
-
#initialize(*types) ⇒ Generic
constructor
A new instance of Generic.
- #new(*values) ⇒ Object
Constructor Details
#initialize(*types) ⇒ Generic
Returns a new instance of Generic.
7 8 9 |
# File 'lib/literal/tuple.rb', line 7 def initialize(*types) @types = types end |
Instance Attribute Details
#types ⇒ Object (readonly)
Returns the value of attribute types.
11 12 13 |
# File 'lib/literal/tuple.rb', line 11 def types @types end |
Instance Method Details
#===(other) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/literal/tuple.rb', line 13 def ===(other) return false unless Literal::Tuple === other types = @types other_types = other.__types__ return false unless types.size == other_types.size i, len = 0, types.size while i < len return false unless Literal.subtype?(other_types[i], types[i]) i += 1 end true end |
#>=(other) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/literal/tuple.rb', line 29 def >=(other) case other when Literal::Tuple::Generic types = @types other_types = other.types return false unless types.size == other_types.size i, len = 0, types.size while i < len return false unless Literal.subtype?(other_types[i], types[i]) i += 1 end true else false end end |
#new(*values) ⇒ Object
49 50 51 |
# File 'lib/literal/tuple.rb', line 49 def new(*values) Literal::Tuple.new(values, @types) end |