class DuckTesting::Type::OrderDependentArray
Attributes
types[R]
Public Class Methods
new(*types)
click to toggle source
# File lib/duck_testing/type/order_dependent_array.rb, line 8 def initialize(*types) @types = types end
Public Instance Methods
match?(array)
click to toggle source
@param [Object] array @return [Boolean]
# File lib/duck_testing/type/order_dependent_array.rb, line 14 def match?(array) return false unless array.is_a?(Array) && array.size == types.size array.zip(types).all? do |array_element, type| type.match?(array_element) end end
to_s()
click to toggle source
@return [String]
# File lib/duck_testing/type/order_dependent_array.rb, line 22 def to_s "Array<(#{types.map(&:to_s).join(', ')})>" end