class DuckTesting::Type::OrderIndependentArray
Attributes
types[R]
Public Class Methods
new(*types)
click to toggle source
# File lib/duck_testing/type/order_independent_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_independent_array.rb, line 14 def match?(array) return false unless array.is_a?(Array) array.all? do |array_element| types.any? { |type| type.match?(array_element) } end end
to_s()
click to toggle source
@return [String]
# File lib/duck_testing/type/order_independent_array.rb, line 22 def to_s "Array<#{types.map(&:to_s).join(', ')}>" end