Method: Enumerable#aT_subset_of
- Defined in:
- lib/y_support/typing/enumerable/typing.rb
#aT_subset_of(other_collection, what_is_receiver_collection = nil, what_is_other_collection = nil) ⇒ Object
Fails with TypeError unless all the collection members are included int the collection supplied as argument. Second optional argument (collection element description) customizes the error message.
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/y_support/typing/enumerable/typing.rb', line 65 def aT_subset_of other_collection, what_is_receiver_collection=nil, what_is_other_collection=nil rc = what_is_receiver_collection ? what_is_receiver_collection.to_s.capitalize : "collection" oc = what_is_other_collection ? what_is_other_collection.to_s.capitalize : "the specified collection" m = "The #{rc} must be a subset of #{oc}" raise TErr, m unless all? { |e| other_collection.include? e } return self end |