Sha256: 9a74e9eba5d98db6b3de382441181b00c0905b98cc220e2be9689c990f87dd92
Contents?: true
Size: 470 Bytes
Versions: 10
Compression:
Stored size: 470 Bytes
Contents
class Redde::UrlGenerator attr_reader :id, :name def initialize(id, name = nil) @id = id @name = name end def url return "#{id}-#{formatted_name}".downcase if formatted_name.present? id.to_s end def translitted_name Russian.translit(name).gsub(' ', '-') .gsub(/[^\x00-\x7F]+/, '').gsub(/[^\w_ \-]+/i, '') .gsub(/[ \-]+/i, '-').gsub(/^\-|\-$/i, '') end def formatted_name name.nil? ? '' : translitted_name end end
Version data entries
10 entries across 10 versions & 1 rubygems