Module: Cardname::Variants
- Included in:
- Cardname
- Defined in:
- cardname/lib/cardname/variants.rb
Instance Method Summary collapse
-
#decoded ⇒ Object
-
#safe_key ⇒ Object
safe to be used in HTML as id (‘*’ and ‘+’ are not allowed), but the key is no longer unique.
-
#simple_key ⇒ Object
-
#to_sym ⇒ Object
-
#url_key ⇒ Object
Instance Method Details
#decoded ⇒ Object
31 32 33 |
# File 'cardname/lib/cardname/variants.rb', line 31 def decoded @decoded ||= s.index("&") ? HTMLEntities.new.decode(s) : s end |
#safe_key ⇒ Object
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
27 28 29 |
# File 'cardname/lib/cardname/variants.rb', line 27 def safe_key key.tr("*", "X").tr self.class.joint, "-" end |
#simple_key ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'cardname/lib/cardname/variants.rb', line 5 def simple_key return "" if empty? decoded .underscore .gsub(/[^#{OK4KEY_RE}]+/, "_") .split(/_+/) .reject(&:empty?) .map { |key| stable_key(key) } .join("_") end |
#to_sym ⇒ Object
35 36 37 |
# File 'cardname/lib/cardname/variants.rb', line 35 def to_sym s.to_sym end |