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.



149
150
151
152
# File 'lib/card/set_pattern.rb', line 149

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



168
169
170
# File 'lib/card/set_pattern.rb', line 168

def inherited_key
  (defined? @inherited_key) ? @inherited_key : @inherited_key = lookup_inherited_key
end

#lookup_inherited_keyObject



154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/card/set_pattern.rb', line 154

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

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

#lookup_module_list(modules_hash) ⇒ Object



172
173
174
# File 'lib/card/set_pattern.rb', line 172

def lookup_module_list modules_hash
  module_key ? modules_hash[ module_key ] : inherited_key && modules_hash[ inherited_key ]
end