Class: AgnosticSlugs::Slug

Inherits:
Object
  • Object
show all
Defined in:
lib/agnostic_slugs/slug.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original, counter = 1) ⇒ Slug

Returns a new instance of Slug.



5
6
7
8
# File 'lib/agnostic_slugs/slug.rb', line 5

def initialize(original, counter = 1)
  @original = original
  @counter  = counter
end

Instance Attribute Details

#counterObject (readonly)

Returns the value of attribute counter.



3
4
5
# File 'lib/agnostic_slugs/slug.rb', line 3

def counter
  @counter
end

#originalObject (readonly)

Returns the value of attribute original.



3
4
5
# File 'lib/agnostic_slugs/slug.rb', line 3

def original
  @original
end

Instance Method Details

#nextObject



10
11
12
# File 'lib/agnostic_slugs/slug.rb', line 10

def next
  self.class.new(original, counter + 1)
end

#to_sObject



14
15
16
# File 'lib/agnostic_slugs/slug.rb', line 14

def to_s
  @slug ||= generate
end