Module: Cardname::Variants
- Included in:
- Cardname
- Defined in:
- 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
28 29 30 |
# File 'lib/cardname/variants.rb', line 28 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
24 25 26 |
# File 'lib/cardname/variants.rb', line 24 def safe_key @safe_key ||= key.tr('*', 'X').tr self.class.joint, '-' end |
#simple_key ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/cardname/variants.rb', line 3 def simple_key return "" if @s.empty? decoded .underscore .gsub(/[^#{OK4KEY_RE}]+/, '_') .split(/_+/) .reject(&:empty?) .map { |key| Cardname.stable_uninflect(key) } .join('_') end |
#to_sym ⇒ Object
32 33 34 |
# File 'lib/cardname/variants.rb', line 32 def to_sym s.to_sym end |