Class: Card::TypeSet

Inherits:
SetPattern show all
Defined in:
lib/card/set_pattern.rb,
tmpsets/set_pattern/102-type.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SetPattern

#anchor_codenames, anchorless?, card_keys, find, #format_module_list, #inspect, junction_only?, #module_key, #module_list, new, pattern, #pattern, register, #rule_set_key, #safe_key, #to_s, write_tmp_file

Constructor Details

#initialize(card) ⇒ TypeSet

Returns a new instance of TypeSet.



154
155
156
157
# File 'lib/card/set_pattern.rb', line 154

def initialize card
  super
  @inherit_card = card unless module_key
end

Class Method Details

.anchor_id(card) ⇒ Object



23
24
25
# File 'tmpsets/set_pattern/102-type.rb', line 23

def anchor_id card
  card.type_id
end

.anchor_name(card) ⇒ Object



19
20
21
# File 'tmpsets/set_pattern/102-type.rb', line 19

def anchor_name card
  card.type_name
end

.follow_label(name) ⇒ Object



27
28
29
# File 'tmpsets/set_pattern/102-type.rb', line 27

def follow_label name
  %{all "#{name}s"}
end

.label(name) ⇒ Object

~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set_pattern/03_type.rb ~~~~~~~~~~~



7
8
9
# File 'tmpsets/set_pattern/102-type.rb', line 7

def label name
  %{All "#{name}" cards}
end

.pattern_applies?(card) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'tmpsets/set_pattern/102-type.rb', line 15

def pattern_applies? card
  !!card.type_id
end

.prototype_args(anchor) ⇒ Object



11
12
13
# File 'tmpsets/set_pattern/102-type.rb', line 11

def prototype_args anchor
  { type: anchor }
end

Instance Method Details

#inherited_keyObject



174
175
176
177
178
179
180
# File 'lib/card/set_pattern.rb', line 174

def inherited_key
  if defined?(@inherited_key)
    @inherited_key
  else
    @inherited_key = lookup_inherited_key
  end
end

#lookup_inherited_keyObject



159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/card/set_pattern.rb', line 159

def lookup_inherited_key
  return unless @inherit_card
  card = @inherit_card
  @inherit_card = nil

  (default_rule = card.rule_card(:default)) &&
    (type_code = default_rule.type_code) &&
    # default_rule.cardname.size > 2 and
    # default_rule.left.right.codename == self.class.pattern_code
    (mod_key = "Type::#{type_code.to_s.camelize}") &&
    (Card::Set.modules[:nonbase_format].values +
      [Card::Set.modules[:nonbase]]).any? { |hash| hash[mod_key] } &&
    mod_key
end

#lookup_module_list(modules_hash) ⇒ Object



182
183
184
185
186
187
188
# File 'lib/card/set_pattern.rb', line 182

def lookup_module_list modules_hash
  if module_key
    modules_hash[module_key]
  else
    inherited_key && modules_hash[inherited_key]
  end
end