Class: Card::Set::Pattern

Inherits:
Object
  • Object
show all
Defined in:
lib/card/set/pattern.rb,
lib/card/set/pattern/all.rb,
lib/card/set/pattern/base.rb,
lib/card/set/pattern/class_methods.rb

Defined Under Namespace

Modules: All, ClassMethods Classes: Base

Class Method Summary collapse

Class Method Details

.card_keysObject



27
28
29
30
31
32
# File 'lib/card/set/pattern.rb', line 27

def card_keys
  @card_keys ||=
    concrete.each_with_object({}) do |set_pattern, hash|
      hash[set_pattern.pattern_id.cardname.key] = true
    end
end

.concreteObject



5
6
7
# File 'lib/card/set/pattern.rb', line 5

def concrete
  @concrete ||= []
end

.find(pattern_code) ⇒ Object



23
24
25
# File 'lib/card/set/pattern.rb', line 23

def find pattern_code
  concrete.find { |sub| sub.pattern_code == pattern_code }
end

.grouped_codes(with_all: true) ⇒ Object



34
35
36
37
38
# File 'lib/card/set/pattern.rb', line 34

def grouped_codes with_all: true
  g = [[:abstract], nonbase_codes.reverse]
  g.unshift [:all] if with_all
  g
end

.idsObject



40
41
42
# File 'lib/card/set/pattern.rb', line 40

def ids
  @ids ||= concrete.map(&:pattern_id)
end

.reloadablesObject



17
18
19
20
21
# File 'lib/card/set/pattern.rb', line 17

def reloadables
  r = concrete.push(Abstract)
  r.delete Set::All
  r
end

.resetObject



9
10
11
12
13
14
15
# File 'lib/card/set/pattern.rb', line 9

def reset
  reloadables.each do |set_pattern|
    Set.const_remove_if_defined set_pattern.to_s.split("::").last
  end
  @concrete = []
  @card_keys = @codes = @nonbase_codes = @ids = nil
end