Module: Card::Set::Rule::Rules

Extended by:
Card::Set
Defined in:
card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb,
card/tmpsets/set/mod037-card-mod-rules/rule/rules.rb

Overview

Set: All rule cards (Rules)

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset_modules

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

#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore

Methods included from AdvancedApi

#attachment, #define_set_from_error, #ensure_set, #setting_opts, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/card-mod-rules/set/rule/rules.rb"; end

Instance Method Details

#event: save_recently_edited_settingsObject



8
9
10
11
12
13
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 8

event :save_recently_edited_settings, :integrate, on: :save, changed: %i[type content] do
  if (recent = Card[:recent_settings])
    recent.insert_item 0, name.right
    attach_subcard recent
  end
end

#first_set_option_index(candidates) ⇒ Object

the narrowest rule should be the one attached to the set being viewed. So, eg, if you’re looking at the ‘*all plus’ set, you shouldn’t have the option to create rules based on arbitrary narrower sets, though narrower sets will always apply to whatever prototype we create



76
77
78
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 76

def first_set_option_index candidates
  new_card? ? 0 : candidates.index { |c| c.to_name.key == rule_set_key }
end

#rule_setObject



31
32
33
34
35
36
37
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 31

def rule_set
  if is_preference?
    self[0..-3]
  else
    trunk
  end
end

#rule_set_keyObject



15
16
17
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 15

def rule_set_key
  rule_set_name.key
end

#rule_set_nameObject



19
20
21
22
23
24
25
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 19

def rule_set_name
  if is_preference?
    name.trunk_name.trunk_name
  else
    name.trunk_name
  end
end

#rule_set_pattern_nameObject



27
28
29
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 27

def rule_set_pattern_name
  rule_set_name.tag_name
end

#rule_settingObject



39
40
41
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 39

def rule_setting
  right
end

#rule_setting_nameObject



43
44
45
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 43

def rule_setting_name
  name.tag
end

#rule_setting_titleObject



51
52
53
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 51

def rule_setting_title
  rule_setting_name.tr "*", ""
end

#rule_user_setting_nameObject



55
56
57
58
59
60
61
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 55

def rule_user_setting_name
  if is_preference?
    "#{rule_user_name}+#{rule_setting_name}"
  else
    rule_setting_name
  end
end

#set_optionsObject

~~~~~~~~~~ determine the set options to which a user can apply the rule.



64
65
66
67
68
69
70
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 64

def set_options
  @set_options ||= [].tap do |set_options|
    set_option_candidates.each do |set_name|
      set_options << [set_name, state_of_set(set_name)]
    end
  end
end

#set_prototypeObject



80
81
82
83
84
85
86
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 80

def set_prototype
  if is_preference?
    self[0..-3].prototype
  else
    trunk.prototype
  end
end

#short_help_textObject



47
48
49
# File 'card/tmpsets/set/mod036-card-mod-rules/rule/rules.rb', line 47

def short_help_text
  Card[rule_setting_name].short_help_text
end