module Cardname::Variants
Public Instance Methods
decoded()
click to toggle source
# File lib/cardname/variants.rb, line 31 def decoded @decoded ||= s.index("&") ? HTMLEntities.new.decode(s) : s end
safe_key()
click to toggle source
safe to be used in HTML as id ('*' and '+' are not allowed), but the key is no longer unique. For example “A-XB” and “A+*B” have the same safe_key
# File lib/cardname/variants.rb, line 27 def safe_key @safe_key ||= key.tr("*", "X").tr self.class.joint, "-" end
simple_key()
click to toggle source
# File lib/cardname/variants.rb, line 5 def simple_key return "" if empty? decoded .underscore .gsub(/[^#{OK4KEY_RE}]+/, "_") .split(/_+/) .reject(&:empty?) .map { |key| self.class.stable_key(key) } .join("_") end
to_sym()
click to toggle source
# File lib/cardname/variants.rb, line 35 def to_sym s.to_sym end
url_key()
click to toggle source
# File lib/cardname/variants.rb, line 17 def url_key @url_key ||= part_names.map do |part_name| stripped = part_name.decoded.gsub(/[^#{OK4KEY_RE}]+/, " ").strip stripped.gsub(/[\s_]+/, "_") end * self.class.joint end