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.4.4 app/models/redde/url_generator.rb
redde-0.4.3 app/models/redde/url_generator.rb
redde-0.4.2 app/models/redde/url_generator.rb
redde-0.4.1 app/models/redde/url_generator.rb
redde-0.4.0 app/models/redde/url_generator.rb
redde-0.3.39 app/models/redde/url_generator.rb
redde-0.3.38 app/models/redde/url_generator.rb
redde-0.3.37 app/models/redde/url_generator.rb
redde-0.3.36 app/models/redde/url_generator.rb
redde-0.3.35 app/models/redde/url_generator.rb
redde-0.3.34 app/models/redde/url_generator.rb
redde-0.3.33 app/models/redde/url_generator.rb
redde-0.3.32 app/models/redde/url_generator.rb
redde-0.3.31 app/models/redde/url_generator.rb
redde-0.3.30 app/models/redde/url_generator.rb
redde-0.3.29 app/models/redde/url_generator.rb
redde-0.3.28 app/models/redde/url_generator.rb
redde-0.3.27 app/models/redde/url_generator.rb
redde-0.3.26 app/models/redde/url_generator.rb
redde-0.3.25 app/models/redde/url_generator.rb