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

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

Overview

pattern-related Card instance methods

Instance Method Summary collapse

Instance Method Details

#concrete_patternsObject



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

def concrete_patterns
  @concrete_patterns ||= Pattern.concrete.map { |sub| sub.new self }.compact
end

#each_type_assigning_module_keyObject



62
63
64
65
66
67
68
69
# File 'lib/card/set/pattern/all.rb', line 62

def each_type_assigning_module_key
  patterns.each do |p|
    next unless p.assigns_type

    module_key = p.module_key
    yield module_key if module_key
  end
end

#in_set?(set_module) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#include_module?(set) ⇒ Boolean

Returns:

  • (Boolean)


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

def include_module? set
  singleton_class&.include? set
end

#patternsObject

new cards do not



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

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

#patterns?Boolean

Returns:

  • (Boolean)


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

def patterns?
  defined? @patterns
end

#reset_patternsObject



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

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

#rule_lookup_keysObject



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

def rule_lookup_keys
  @rule_lookup_keys ||= patterns.map(&:rule_lookup_key).compact
end

#safe_set_keysObject



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

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

#set_format_modules(klass) ⇒ Object



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

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

#set_modulesObject



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

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

#set_namesObject



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

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