Module: Card::Set::Rstar::Rules
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod007-05_standard/rstar/rules.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_on_format, ensure_set, extended, format, process_base_module_list, process_base_modules, register_set, register_set_format, shortname, stage_method, view, write_tmp_file
Methods included from Event
#define_event, #event
Instance Method Details
24
25
26
27
28
29
30
|
# File 'tmpsets/set/mod007-05_standard/rstar/rules.rb', line 24
def rule_set
if is_user_rule?
self[0..-3]
else
trunk
end
end
|
#rule_set_key ⇒ Object
12
13
14
|
# File 'tmpsets/set/mod007-05_standard/rstar/rules.rb', line 12
def rule_set_key
rule_set_name.key
end
|
#rule_set_name ⇒ Object
16
17
18
19
20
21
22
|
# File 'tmpsets/set/mod007-05_standard/rstar/rules.rb', line 16
def rule_set_name
if is_user_rule?
cardname.trunk_name.trunk_name
else
cardname.trunk_name
end
end
|
#rule_setting_name ⇒ Object
32
33
34
|
# File 'tmpsets/set/mod007-05_standard/rstar/rules.rb', line 32
def rule_setting_name
cardname.tag
end
|
#rule_user ⇒ Object
48
49
50
|
# File 'tmpsets/set/mod007-05_standard/rstar/rules.rb', line 48
def rule_user
is_user_rule? ? self[-2] : nil
end
|
#rule_user_name ⇒ Object
44
45
46
|
# File 'tmpsets/set/mod007-05_standard/rstar/rules.rb', line 44
def rule_user_name
is_user_rule? ? cardname.trunk_name.tag : nil
end
|
#rule_user_setting_name ⇒ Object
36
37
38
39
40
41
42
|
# File 'tmpsets/set/mod007-05_standard/rstar/rules.rb', line 36
def rule_user_setting_name
if is_user_rule?
"#{rule_user_name}+#{rule_setting_name}"
else
rule_setting_name
end
end
|
#set_options ⇒ Object
~~~~~~~~~~ determine the set options to which the user can apply the rule.
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'tmpsets/set/mod007-05_standard/rstar/rules.rb', line 53
def set_options
first = if new_card?
0
else
set_prototype.set_names.index { |s| s.to_name.key == rule_set_key }
end
rule_cnt = 0
res = []
fallback_set = nil
set_prototype.set_names[first..-1].each do |set_name|
if Card.exists?("#{set_name}+#{rule_user_setting_name}")
rule_cnt += 1
res << if rule_cnt == 1
[set_name, :current]
else
fallback_set ||= set_name
[set_name, :overwritten]
end
else
res << (rule_cnt < 1 ? [set_name, :enabled] : [set_name, :disabled])
end
end
return res, fallback_set
end
|
#set_prototype ⇒ Object
97
98
99
100
101
102
103
|
# File 'tmpsets/set/mod007-05_standard/rstar/rules.rb', line 97
def set_prototype
if is_user_rule?
self[0..-3].prototype
else
trunk.prototype
end
end
|