Module: Card::Set::Pattern::All

Included in:
Card
Defined in:
card/lib/card/set/pattern/all.rb

Overview

pattern-related Card instance methods

Instance Method Summary collapse

Instance Method Details

#all_patternsObject



10
11
12
# File 'card/lib/card/set/pattern/all.rb', line 10

def all_patterns
  @all_patterns ||= set_patterns.map { |sub| sub.new self }.compact
end

#in_set?(set_module) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'card/lib/card/set/pattern/all.rb', line 49

def in_set? set_module
  patterns.map(&:module_key).include? set_module.shortname
end

#include_module?(set) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'card/lib/card/set/pattern/all.rb', line 57

def include_module? set
  singleton_class&.include? set
end

#patternsObject

new cards do not



15
16
17
# File 'card/lib/card/set/pattern/all.rb', line 15

def patterns
  @patterns ||= (new_card? ? all_patterns[1..-1] : all_patterns)
end

#patterns?Boolean

Returns:

  • (Boolean)


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

def patterns?
  defined? @patterns
end

#reset_patternsObject



19
20
21
22
23
24
25
26
# File 'card/lib/card/set/pattern/all.rb', line 19

def reset_patterns
  # Rails.logger.info "resetting patterns: #{name}"
  @patterns = @all_patterns = nil
  @template = @virtual = nil
  @set_mods_loaded = @set_modules = @set_names = @rule_set_keys = nil
  @junction_only = nil # only applies to set cards
  true
end

#rule_set_keysObject



53
54
55
# File 'card/lib/card/set/pattern/all.rb', line 53

def rule_set_keys
  @rule_set_keys ||= patterns.map(&:rule_set_key).compact
end

#safe_set_keysObject



28
29
30
# File 'card/lib/card/set/pattern/all.rb', line 28

def safe_set_keys
  patterns.map(&:safe_key).reverse * " "
end

#set_format_modules(klass) ⇒ Object



36
37
38
39
40
41
42
# File 'card/lib/card/set/pattern/all.rb', line 36

def set_format_modules klass
  @set_format_modules ||= {}
  @set_format_modules[klass] =
    all_patterns[0..-2].reverse.map do |pattern|
      pattern.format_module_list klass
    end.flatten.compact
end

#set_modulesObject



32
33
34
# File 'card/lib/card/set/pattern/all.rb', line 32

def set_modules
  @set_modules ||= all_patterns[0..-2].reverse.map(&:module_list).flatten.compact
end

#set_namesObject



44
45
46
47
# File 'card/lib/card/set/pattern/all.rb', line 44

def set_names
  @set_names = patterns.map(&:to_s) if @set_names.nil?
  @set_names
end