Class: Shrinker::Extractor

Inherits:
Struct
  • Object
show all
Defined in:
lib/shrinker/extractor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#config=(value) ⇒ Object

Sets the attribute config

Parameters:

  • value (Object)

    the value to set the attribute config to.

Returns:

  • (Object)

    the newly set value



2
3
4
# File 'lib/shrinker/extractor.rb', line 2

def config=(value)
  @config = value
end

#tokenObject

Returns the value of attribute token

Returns:

  • (Object)

    the current value of token



2
3
4
# File 'lib/shrinker/extractor.rb', line 2

def token
  @token
end

Class Method Details

.unshrink(token, config = nil) ⇒ Object



3
4
5
# File 'lib/shrinker/extractor.rb', line 3

def self.unshrink(token, config = nil)
  self.new(token, config).unshrink
end

Instance Method Details

#unshrinkObject

Raises:



7
8
9
10
11
12
# File 'lib/shrinker/extractor.rb', line 7

def unshrink
  stored_content = backend.fetch(token)
  raise UrlNotFound.new("Cannot find the url with token: #{token}") if stored_content == {}

  EasyUrl.new(stored_content['url'], stored_content['attributes'] || {})
end