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

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-defaults/mod010-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

Methods included from I18nScope

#mod_name, #scope

Methods included from Card::Set::Registrar

#extended, #finalize_load, #process_base_modules, #register_set

Methods included from Helpers

#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name

Methods included from AdvancedApi

#assign_type, #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 Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'platypus/tmp/set/gem-defaults/mod010-rules/rule/rules.rb', line 7

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

Instance Method Details

#event: save_recently_edited_settingsObject



8
9
10
11
12
13
# File 'platypus/tmp/set/gem-defaults/mod010-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
    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 'platypus/tmp/set/gem-defaults/mod010-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 'platypus/tmp/set/gem-defaults/mod010-rules/rule/rules.rb', line 31

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

#rule_set_keyObject



15
16
17
# File 'platypus/tmp/set/gem-defaults/mod010-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 'platypus/tmp/set/gem-defaults/mod010-rules/rule/rules.rb', line 19

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

#rule_set_pattern_nameObject



27
28
29
# File 'platypus/tmp/set/gem-defaults/mod010-rules/rule/rules.rb', line 27

def rule_set_pattern_name
  rule_set_name.tag_name
end

#rule_settingObject



39
40
41
# File 'platypus/tmp/set/gem-defaults/mod010-rules/rule/rules.rb', line 39

def rule_setting
  right
end

#rule_setting_nameObject



43
44
45
# File 'platypus/tmp/set/gem-defaults/mod010-rules/rule/rules.rb', line 43

def rule_setting_name
  name.tag
end

#rule_setting_titleObject



51
52
53
# File 'platypus/tmp/set/gem-defaults/mod010-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 'platypus/tmp/set/gem-defaults/mod010-rules/rule/rules.rb', line 55

def rule_user_setting_name
  if 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 'platypus/tmp/set/gem-defaults/mod010-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 'platypus/tmp/set/gem-defaults/mod010-rules/rule/rules.rb', line 80

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

#short_help_textObject



47
48
49
# File 'platypus/tmp/set/gem-defaults/mod010-rules/rule/rules.rb', line 47

def short_help_text
  Card[rule_setting_name].short_help_text
end