Sha256: c5b4b426118e9347c207d28c951d37e5638f4a32198719ad7e9ab84c7a8f6e06
Contents?: true
Size: 496 Bytes
Versions: 45
Compression:
Stored size: 496 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) .tr(' ', '-') .gsub(/[^\x00-\x7F]+/, '') .gsub(/[^\w_ \-]+/i, '') .gsub(/[ \-]+/i, '-') .gsub(/^\-|\-$/i, '') end def formatted_name name.nil? ? '' : translitted_name end end
Version data entries
45 entries across 45 versions & 1 rubygems