Class: Embiggen::URI
- Inherits:
-
Object
- Object
- Embiggen::URI
- Defined in:
- lib/embiggen/uri.rb
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #expand(request_options = {}) ⇒ Object
- #expand!(request_options = {}) ⇒ Object
-
#initialize(uri) ⇒ URI
constructor
A new instance of URI.
- #shortened? ⇒ Boolean
Constructor Details
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/embiggen/uri.rb', line 6 def uri @uri end |
Instance Method Details
#expand(request_options = {}) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/embiggen/uri.rb', line 12 def ( = {}) () rescue TooManyRedirects => error error.uri rescue StandardError, ::Timeout::Error uri end |
#expand!(request_options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/embiggen/uri.rb', line 20 def ( = {}) return uri unless shortened? redirects = .fetch(:redirects) { Configuration.redirects } check_redirects(redirects) location = head_location() check_location(location) URI.new(location). (.merge(:redirects => redirects - 1)) end |
#shortened? ⇒ Boolean
33 34 35 |
# File 'lib/embiggen/uri.rb', line 33 def shortened? Configuration.shorteners.any? { |domain| uri.host =~ /\b#{domain}\z/i } end |