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

Extended by:
Card::Set
Defined in:
tmpsets/set/mod001-01_core/all/pattern.rb

Instance Method Summary collapse

Methods included from Card::Set

abstract_set?, all_set?, card_accessor, card_reader, card_writer, clean_empty_module_from_hash, clean_empty_modules, define_active_job, define_event_method, define_event_perform_later_method, define_on_format, ensure_set, event, extended, format, phase_method, process_base_module_list, process_base_modules, register_set, register_set_format, shortname, view, write_tmp_file

Instance Method Details

#patternsObject

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



5
6
7
# File 'tmpsets/set/mod001-01_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/mod001-01_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
# File 'tmpsets/set/mod001-01_core/all/pattern.rb', line 14

def reset_patterns
  @set_mods_loaded = @patterns = @set_modules = @junction_only = @set_names = @template = @rule_set_keys = @virtual = nil
  true
end

#reset_patterns_if_rule(saving = false) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'tmpsets/set/mod001-01_core/all/pattern.rb', line 19

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
      self.add_to_read_rule_update_queue(set.item_cards limit: 0)
    end
  end
end

#rule_set_keysObject



57
58
59
60
# File 'tmpsets/set/mod001-01_core/all/pattern.rb', line 57

def rule_set_keys
  set_names # this triggers set_members cache.  need better solution!
  @rule_set_keys ||= patterns.map(&:rule_set_key).compact
end

#safe_set_keysObject



32
33
34
# File 'tmpsets/set/mod001-01_core/all/pattern.rb', line 32

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

#set_format_modules(klass) ⇒ Object



41
42
43
44
45
46
47
# File 'tmpsets/set/mod001-01_core/all/pattern.rb', line 41

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



36
37
38
39
# File 'tmpsets/set/mod001-01_core/all/pattern.rb', line 36

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

#set_namesObject



49
50
51
52
53
54
55
# File 'tmpsets/set/mod001-01_core/all/pattern.rb', line 49

def set_names
  if @set_names.nil?
    @set_names = patterns.map &:to_s
    Card.set_members @set_names, key
  end
  @set_names
end