Class: Smeargle::Sketch

Inherits:
Object
  • Object
show all
Includes:
Image
Defined in:
lib/smeargle/sketch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_heightObject

Returns the value of attribute min_height.



6
7
8
# File 'lib/smeargle/sketch.rb', line 6

def min_height
  @min_height
end

#min_widthObject

Returns the value of attribute min_width.



6
7
8
# File 'lib/smeargle/sketch.rb', line 6

def min_width
  @min_width
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/smeargle/sketch.rb', line 6

def url
  @url
end

Instance Method Details

#clean_urlObject



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_bodyObject



20
21
22
# File 'lib/smeargle/sketch.rb', line 20

def response_body
  @response_body ||= Nokogiri::HTML(open safe_url)
end

#safe_urlObject



15
16
17
18
# File 'lib/smeargle/sketch.rb', line 15

def safe_url
  @safe_url ||=
    !URI.parse(url).scheme ? "http://#{url}" : url
end