module SmartName::Variants
Public Instance Methods
decoded()
click to toggle source
# File lib/smart_name/variants.rb 28 def decoded 29 @decoded ||= s.index('&') ? HTMLEntities.new.decode(s) : s 30 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/smart_name/variants.rb 24 def safe_key 25 @safe_key ||= key.tr('*', 'X').tr self.class.joint, '-' 26 end
simple_key()
click to toggle source
# File lib/smart_name/variants.rb 3 def simple_key 4 return "" if @s.empty? 5 decoded 6 .underscore 7 .gsub(/[^#{OK4KEY_RE}]+/, '_') 8 .split(/_+/) 9 .reject(&:empty?) 10 .map { |key| SmartName.stable_uninflect(key) } 11 .join('_') 12 end
to_sym()
click to toggle source
# File lib/smart_name/variants.rb 32 def to_sym 33 s.to_sym 34 end
url_key()
click to toggle source
# File lib/smart_name/variants.rb 14 def url_key 15 @url_key ||= part_names.map do |part_name| 16 stripped = part_name.decoded.gsub(/[^#{OK4KEY_RE}]+/, ' ').strip 17 stripped.gsub(/[\s\_]+/, '_') 18 end * self.class.joint 19 end