Class: Smeargle::Sketch
- Inherits:
-
Object
- Object
- Smeargle::Sketch
- Includes:
- Image
- Defined in:
- lib/smeargle/sketch.rb
Instance Attribute Summary collapse
-
#min_height ⇒ Object
Returns the value of attribute min_height.
-
#min_width ⇒ Object
Returns the value of attribute min_width.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #clean_url ⇒ Object
-
#initialize(url, args = {}) ⇒ Sketch
constructor
A new instance of Sketch.
- #response_body ⇒ Object
- #safe_url ⇒ Object
Methods included from Image
#corrupt?, #detailed_images, #filtered_images, #format_image_url, #formatted_images, #image_collection, #image_details, #images
Constructor Details
#initialize(url, args = {}) ⇒ Sketch
Returns a new instance of Sketch.
8 9 10 11 12 13 |
# File 'lib/smeargle/sketch.rb', line 8 def initialize url, args = {} @url = url args.each do |key, value| send "#{key}=", value end end |
Instance Attribute Details
#min_height ⇒ Object
Returns the value of attribute min_height.
6 7 8 |
# File 'lib/smeargle/sketch.rb', line 6 def min_height @min_height end |
#min_width ⇒ Object
Returns the value of attribute min_width.
6 7 8 |
# File 'lib/smeargle/sketch.rb', line 6 def min_width @min_width end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/smeargle/sketch.rb', line 6 def url @url end |
Instance Method Details
#clean_url ⇒ Object
24 25 26 27 28 |
# File 'lib/smeargle/sketch.rb', line 24 def clean_url @clean_url ||= URI(safe_url).scheme + '://' + URI(safe_url).host end |
#response_body ⇒ Object
20 21 22 |
# File 'lib/smeargle/sketch.rb', line 20 def response_body @response_body ||= Nokogiri::HTML(open safe_url) end |
#safe_url ⇒ Object
15 16 17 18 |
# File 'lib/smeargle/sketch.rb', line 15 def safe_url @safe_url ||= !URI.parse(url).scheme ? "http://#{url}" : url end |