Class: Simpl::Url

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/simpl/url.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Url

required: url to be shortened



12
13
14
15
16
17
18
19
# File 'lib/simpl/url.rb', line 12

def initialize(url, options = {})
  # sets the URL to be shortened
  self.url = url
  # allows an instance-level override for the api key
  @api_key = options[:api_key]
  # allows an instance-level override for the timeout
  @timeout = options[:timeout]
end

Instance Attribute Details

#urlObject

Returns the value of attribute url.



9
10
11
# File 'lib/simpl/url.rb', line 9

def url
  @url
end

Instance Method Details

#shortenedObject

returns: a string respresenting the shortened url note: may be still the full url should a problem occur



23
24
25
# File 'lib/simpl/url.rb', line 23

def shortened
  @shortened ||= shorten
end