Class: Shaped::Shapes::All
- Inherits:
-
Shaped::Shape
- Object
- Shaped::Shape
- Shaped::Shapes::All
- Defined in:
- lib/shaped/shapes/all.rb
Instance Method Summary collapse
-
#initialize(*shape_descriptions) ⇒ All
constructor
A new instance of All.
- #matched_by?(object) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(*shape_descriptions) ⇒ All
Returns a new instance of All.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/shaped/shapes/all.rb', line 4 def initialize(*shape_descriptions) = shape_descriptions. if shape_descriptions.size <= 1 raise(Shaped::InvalidShapeDescription, <<~ERROR.squish) A #{self.class} description must be a list of two or more shape descriptions. ERROR end @shapes = shape_descriptions.map do |description| Shaped::Shape(description, ) end end |
Instance Method Details
#matched_by?(object) ⇒ Boolean
18 19 20 |
# File 'lib/shaped/shapes/all.rb', line 18 def matched_by?(object) @shapes.all? { |shape| shape.matched_by?(object) } end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/shaped/shapes/all.rb', line 22 def to_s @shapes.map(&:to_s).join(' AND ') end |