0.01
No release in over a year
Type-checked set
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
 Dependencies

Development

 Project Readme

collection

Type-checked set

Example

type = String

collection = Collection::Set.new(type)

collection.add('something')

collection.entry? { |v| v == 'something' }
# => true

collection.entry?('something')
# => true

collection.add(:not_a_string)
# => ArgumentError (:not_a_string must be a String)

Generic-Style

type = String

cls = Collection::Set[type]

cls
# => "Collection::Set::String"

collection = cls.new

collection.add('something')

collection.entry? { |v| v == 'something' }
# => true

collection.entry?('something')
# => true

collection.add(:not_a_string)
# => ArgumentError (:not_a_string must be a String)

Factory Method

things = ['Thing 1', 'Thing 2']

collection = Collection::Set(things)

collection.entry? { |v| v == 'Thing 1' }
# => true

collection.entry?('Thing 1')
# => true

collection.add(:not_a_string)
# => ArgumentError (:not_a_string must be a String)

Constructor

things = ['Thing 1', 'Thing 2']

collection = Collection::Set[String].build(things)

collection.entry? { |v| v == 'Thing 1' }
# => true

collection.entry?('Thing 1')
# => true

collection.add(:not_a_string)
# => ArgumentError (:not_a_string must be a String)

License

The collection library is released under the MIT License.