Module: Card::Set::Pattern
- Defined in:
- card/lib/card/set/pattern.rb,
card/lib/card/set/pattern/all.rb,
card/lib/card/set/pattern/base.rb,
card/lib/card/set/pattern/class_methods.rb
Overview
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.
Defined Under Namespace
Modules: All, ClassMethods Classes: Base
Class Method Summary collapse
-
.codes ⇒ Array <Symbol>
list of codenames of pattern cards.
-
.concrete ⇒ Array <Class>
Pattern classes all the patterns except for Abstract.
-
.find(pattern_code) ⇒ Class
finds pattern class associated with codename e.g.
-
.grouped_codes(with_all: true) ⇒ Array <Array <Symbol>>
list of lists of codenames in pattern load order.
-
.ids ⇒ Array <Integer>
list of ids of pattern cards.
-
.reloadables ⇒ Array <Class>
Pattern classes that can be reloaded without reloading Card (everything but all).
-
.reset ⇒ Object
remove reloadable sets and prepare for reloading.
Class Method Details
.codes ⇒ Array <Symbol>
list of codenames of pattern cards
41 42 43 |
# File 'card/lib/card/set/pattern.rb', line 41 def codes @codes ||= concrete.map(&:pattern_code).to_set end |
.concrete ⇒ Array <Class>
Pattern classes all the patterns except for Abstract. They are concrete because they are defined on a set of cards (while abstract sets must be included on them explicitly).
12 13 14 |
# File 'card/lib/card/set/pattern.rb', line 12 def concrete @concrete ||= [] end |
.find(pattern_code) ⇒ Class
finds pattern class associated with codename
e.g. find(:type) returns Card::Set::Type
35 36 37 |
# File 'card/lib/card/set/pattern.rb', line 35 def find pattern_code concrete.find { |sub| sub.pattern_code == pattern_code } end |
.grouped_codes(with_all: true) ⇒ Array <Array <Symbol>>
list of lists of codenames in pattern load order
47 48 49 50 51 |
# File 'card/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 |
.ids ⇒ Array <Integer>
list of ids of pattern cards
55 56 57 |
# File 'card/lib/card/set/pattern.rb', line 55 def ids @ids ||= concrete.map(&:pattern_id) end |
.reloadables ⇒ Array <Class>
Pattern classes that can be reloaded without reloading Card (everything but all)
19 20 21 |
# File 'card/lib/card/set/pattern.rb', line 19 def reloadables concrete - [Set::All] + Abstract end |
.reset ⇒ Object
remove reloadable sets and prepare for reloading
24 25 26 27 28 29 |
# File 'card/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 |