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

Extended by:
Card::Set
Defined in:
tmpsets/set/mod002-core/all/pattern.rb

Constant Summary

Constants included from Format

Format::TEMPLATE_DIR

Instance Method Summary collapse

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#abstract_set?, #all_set?, #num_set_parts, #shortname, #underscore

Methods included from Card::Set::AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#all_set_format_mod!, #before, #define_on_format, #format, layout_method_name, #register_set_format, #view, #view_for_override, view_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Instance Method Details

#in_set?(set_module) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'tmpsets/set/mod002-core/all/pattern.rb', line 57

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

#patternsObject

~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/core/set/all/pattern.rb ~~



5
6
7
# File 'tmpsets/set/mod002-core/all/pattern.rb', line 5

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

#patterns_with_newObject



9
10
11
# File 'tmpsets/set/mod002-core/all/pattern.rb', line 9

def patterns_with_new
  new_card? ? patterns_without_new[1..-1] : patterns_without_new
end

#reset_patternsObject



14
15
16
17
18
19
20
# File 'tmpsets/set/mod002-core/all/pattern.rb', line 14

def reset_patterns
  @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

#reset_patterns_if_rule(saving = false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'tmpsets/set/mod002-core/all/pattern.rb', line 22

def reset_patterns_if_rule saving=false
  if !new_card? && is_rule?
    set = left
    set.reset_patterns
    set.include_set_modules

    # FIXME: should be in right/read.rb
    if saving && right.id == Card::ReadID
      add_to_read_rule_update_queue set.item_cards(limit: 0)
    end
  end
end

#rule_set_keysObject



61
62
63
# File 'tmpsets/set/mod002-core/all/pattern.rb', line 61

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

#safe_set_keysObject



35
36
37
# File 'tmpsets/set/mod002-core/all/pattern.rb', line 35

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

#set_format_modules(klass) ⇒ Object



44
45
46
47
48
49
50
# File 'tmpsets/set/mod002-core/all/pattern.rb', line 44

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

#set_modulesObject



39
40
41
42
# File 'tmpsets/set/mod002-core/all/pattern.rb', line 39

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

#set_namesObject



52
53
54
55
# File 'tmpsets/set/mod002-core/all/pattern.rb', line 52

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