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
- #concrete_patterns ⇒ Object
- #each_type_assigning_module_key ⇒ Object
- #in_set?(set_module) ⇒ Boolean
- #include_module?(set) ⇒ Boolean
-
#patterns ⇒ Object
new cards do not.
- #patterns? ⇒ Boolean
- #reset_patterns ⇒ Object
- #rule_lookup_keys ⇒ Object
- #safe_set_keys ⇒ Object
- #set_format_modules(klass) ⇒ Object
- #set_modules ⇒ Object
- #set_names ⇒ Object
Instance Method Details
#concrete_patterns ⇒ Object
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_key ⇒ Object
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
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
58 59 60 |
# File 'lib/card/set/pattern/all.rb', line 58 def include_module? set singleton_class&.include? set end |
#patterns ⇒ Object
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
6 7 8 |
# File 'lib/card/set/pattern/all.rb', line 6 def patterns? defined? @patterns end |
#reset_patterns ⇒ Object
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_keys ⇒ Object
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_keys ⇒ Object
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_modules ⇒ Object
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_names ⇒ Object
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 |