Sha256: a70d768685817edf7893e503b719abc51e1d0c834f601736c89782863d1f1f71

Contents?: true

Size: 497 Bytes

Versions: 17

Compression:

Stored size: 497 Bytes

Contents

# frozen_string_literal: true

class Shaped::Shapes::Array < Shaped::Shape
  def initialize(shape_description)
    if !shape_description.is_a?(Array)
      raise(Shaped::InvalidShapeDescription, "A #{self.class} description must be an array.")
    end

    @element_test = Shaped::Shape(*shape_description)
  end

  def matched_by?(array)
    return false if !array.is_a?(Array)

    array.all? { |element| @element_test.matched_by?(element) }
  end

  def to_s
    "[#{@element_test}]"
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
shaped-0.14.0 lib/shaped/shapes/array.rb
shaped-0.13.0 lib/shaped/shapes/array.rb
shaped-0.12.0 lib/shaped/shapes/array.rb
shaped-0.11.0 lib/shaped/shapes/array.rb
shaped-0.10.0 lib/shaped/shapes/array.rb
shaped-0.9.1 lib/shaped/shapes/array.rb
shaped-0.9.0 lib/shaped/shapes/array.rb
shaped-0.8.2 lib/shaped/shapes/array.rb
shaped-0.8.0 lib/shaped/shapes/array.rb
shaped-0.7.3 lib/shaped/shapes/array.rb
shaped-0.7.2 lib/shaped/shapes/array.rb
shaped-0.7.1 lib/shaped/shapes/array.rb
shaped-0.7.0 lib/shaped/shapes/array.rb
shaped-0.6.4 lib/shaped/shapes/array.rb
shaped-0.6.3 lib/shaped/shapes/array.rb
shaped-0.6.2 lib/shaped/shapes/array.rb
shaped-0.6.1 lib/shaped/shapes/array.rb