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

Version Path
redde-0.3.24 app/models/redde/url_generator.rb
redde-0.3.23 app/models/redde/url_generator.rb
redde-0.3.22 app/models/redde/url_generator.rb
redde-0.3.21 app/models/redde/url_generator.rb
redde-0.3.20 app/models/redde/url_generator.rb
redde-0.3.19 app/models/redde/url_generator.rb
redde-0.3.18 app/models/redde/url_generator.rb
redde-0.3.17 app/models/redde/url_generator.rb
redde-0.3.16 app/models/redde/url_generator.rb
redde-0.3.15 app/models/redde/url_generator.rb
redde-0.3.14 app/models/redde/url_generator.rb
redde-0.3.13 app/models/redde/url_generator.rb
redde-0.3.12 app/models/redde/url_generator.rb
redde-0.3.11 app/models/redde/url_generator.rb
redde-0.3.10 app/models/redde/url_generator.rb
redde-0.3.9 app/models/redde/url_generator.rb
redde-0.3.8 app/models/redde/url_generator.rb
redde-0.3.7 app/models/redde/url_generator.rb
redde-0.3.6 app/models/redde/url_generator.rb
redde-0.3.5 app/models/redde/url_generator.rb