module Card::Set::Pattern
Each deck can have countless sets of cards, each of which follows one of a small list of patterns. This module provides methods for managing those patterns.
Public Class Methods
Source
# File lib/card/set/pattern.rb, line 41 def codes @codes ||= concrete.to_set(&:pattern_code) end
list of codenames of pattern cards @return [Array <Symbol>]
Source
Source
# File lib/card/set/pattern.rb, line 35 def find pattern_code concrete.find { |sub| sub.pattern_code == pattern_code } end
finds pattern class associated with codename e.g. find(:type) returns ‘Card::Set::Type`
@return [Class] pattern class
Source
# File lib/card/set/pattern.rb, line 47 def grouped_codes with_all: true g = [[:abstract], nonbase_codes.reverse] g.unshift [:all] if with_all g end
list of lists of codenames in pattern load order @return [Array <Array <Symbol>>]
Source
# File lib/card/set/pattern.rb, line 55 def ids @ids ||= concrete.map(&:pattern_id) end
list of ids of pattern cards @return [Array <Integer>]
Source
Source
# File lib/card/set/pattern.rb, line 24 def reset reloadables.each do |set_pattern| Set.const_remove_if_defined set_pattern.to_s.split("::").last end @concrete = @codes = @type_assigner_codes = @nonbase_codes = @ids = nil end
remove reloadable sets and prepare for reloading
Private Class Methods
Source
# File lib/card/set/pattern.rb, line 61 def nonbase_codes @nonbase_codes ||= codes.to_a - [:all] end