Sha256: 05db952311c5c74c45a7a279277444548947c623570acc6219a930d68509431a
Contents?: true
Size: 670 Bytes
Versions: 1
Compression:
Stored size: 670 Bytes
Contents
module CardsLib module IsSet class << self def verify(cards, rules = [:unique, :paired], specs = {}) max = specs.fetch(:max) {Float::INFINITY} min = specs.fetch(:min) { 3 } rules.all? {|r| send(r, cards) } && (min..max).include?(cards.count) end private def unique(cards) cards.combination(2).all? {|a, b| a != b } end using Refinements::InjectWhile def paired(cards) cards.inject_while?(:paired?) end def suited(cards) cards.inject_while?(:suited?) end def ordered(cards) cards.sort.inject_while?(:ordered?) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cards_lib-0.2.5 | lib/cards_lib/is_set.rb |