Class: Embiggen::URI
- Inherits:
-
Object
- Object
- Embiggen::URI
- Defined in:
- lib/embiggen/uri.rb
Instance Attribute Summary collapse
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #expand(request_options = {}) ⇒ Object
-
#initialize(uri) ⇒ URI
constructor
A new instance of URI.
- #shortened? ⇒ Boolean
Constructor Details
#initialize(uri) ⇒ URI
Returns a new instance of URI.
11 12 13 14 |
# File 'lib/embiggen/uri.rb', line 11 def initialize(uri) @uri = URI(::Addressable::URI.parse(uri).normalize.to_s) @http_client = HttpClient.new(@uri) end |
Instance Attribute Details
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
9 10 11 |
# File 'lib/embiggen/uri.rb', line 9 def http_client @http_client end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
9 10 11 |
# File 'lib/embiggen/uri.rb', line 9 def uri @uri end |
Instance Method Details
#expand(request_options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/embiggen/uri.rb', line 16 def ( = {}) return uri unless shortened? redirects = extract_redirects() location = follow() self.class.new(location). (.merge(:redirects => redirects - 1)) end |
#shortened? ⇒ Boolean
26 27 28 |
# File 'lib/embiggen/uri.rb', line 26 def shortened? Configuration.shorteners.include?(uri) end |