class Card::Set::Pattern::Base
class from which set patterns inherit
Public Class Methods
new(card)
click to toggle source
# File lib/card/set/pattern/base.rb, line 10 def initialize card return if anchorless? @anchor_name = self.class.anchor_name(card).to_name @anchor_id = find_anchor_id card end
Public Instance Methods
anchor_codenames()
click to toggle source
# File lib/card/set/pattern/base.rb, line 40 def anchor_codenames anchor_parts.map do |part| part.cardname&.codename || break end end
anchor_parts()
click to toggle source
# File lib/card/set/pattern/base.rb, line 46 def anchor_parts return [@anchor_name] unless anchor_parts_count > 1 parts = @anchor_name.parts if parts.size <= anchor_parts_count parts else # handles cases where anchor is a compound card, eg A+B+*self [@anchor_name[0..-anchor_parts_count]] + parts[(-anchor_parts_count + 1)..-1] end end
find_anchor_id(card)
click to toggle source
# File lib/card/set/pattern/base.rb, line 17 def find_anchor_id card self.class.try(:anchor_id, card) || @anchor_name.card_id end
format_module_list(klass)
click to toggle source
# File lib/card/set/pattern/base.rb, line 35 def format_module_list klass hash = Card::Set.modules[:nonbase_format][klass] hash && lookup_module_list(hash) end
inspect()
click to toggle source
# File lib/card/set/pattern/base.rb, line 62 def inspect "<#{self.class} #{to_s.to_name.inspect}>" end
lookup_module_list(modules_hash)
click to toggle source
# File lib/card/set/pattern/base.rb, line 27 def lookup_module_list modules_hash module_key && modules_hash[module_key] end
module_key()
click to toggle source
# File lib/card/set/pattern/base.rb, line 21 def module_key return @module_key if defined? @module_key @module_key = self.class.module_key anchor_codenames end
module_list()
click to toggle source
# File lib/card/set/pattern/base.rb, line 31 def module_list lookup_module_list Card::Set.modules[:nonbase] end
rule_lookup_key()
click to toggle source
# File lib/card/set/pattern/base.rb, line 71 def rule_lookup_key if anchorless? pattern_code.to_s elsif @anchor_id "#{@anchor_id}+#{pattern_code}" end end
safe_key()
click to toggle source
# File lib/card/set/pattern/base.rb, line 66 def safe_key caps_part = pattern_code.to_s.tr(" ", "_").upcase anchorless? ? caps_part : "#{caps_part}-#{@anchor_name.safe_key}" end
to_s()
click to toggle source
# File lib/card/set/pattern/base.rb, line 58 def to_s anchorless? ? pattern.s : "#{@anchor_name}+#{pattern}" end