Class: Shortie::BaseShortener

Inherits:
Object
  • Object
show all
Defined in:
lib/shortie/base_shortener.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ BaseShortener

Returns a new instance of BaseShortener.



10
11
12
# File 'lib/shortie/base_shortener.rb', line 10

def initialize(url)
  self.url = url
end

Instance Attribute Details

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/shortie/base_shortener.rb', line 3

def url
  @url
end

Class Method Details

.shorten(url) ⇒ Object

Shortens a url.



6
7
8
# File 'lib/shortie/base_shortener.rb', line 6

def self.shorten(url)
  self.new(url).shorten
end

Instance Method Details

#shortenObject

Shorten method to be called. Must be implemented by classes inheriting this class.



15
16
17
# File 'lib/shortie/base_shortener.rb', line 15

def shorten
  raise "Invalid shortener. It must implement the shorten method."
end