Class: Artimis::Camera
- Inherits:
-
Object
- Object
- Artimis::Camera
- Defined in:
- lib/artimis/camera.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#image_url ⇒ Object
readonly
Returns the value of attribute image_url.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(page, params = {}) ⇒ Camera
constructor
A new instance of Camera.
Constructor Details
#initialize(page, params = {}) ⇒ Camera
Returns a new instance of Camera.
47 48 49 50 51 52 53 54 |
# File 'lib/artimis/camera.rb', line 47 def initialize(page, params = {}) self.description = params[:description] || page.to_s self.url = params[:url] || page.href page.images.each do |i| self.image_url = i.url if i.node.attributes["name"] end end |
Class Attribute Details
.url ⇒ Object
6 7 8 |
# File 'lib/artimis/camera.rb', line 6 def url @url ||= list_url end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
45 46 47 |
# File 'lib/artimis/camera.rb', line 45 def description @description end |
#image_url ⇒ Object
Returns the value of attribute image_url.
45 46 47 |
# File 'lib/artimis/camera.rb', line 45 def image_url @image_url end |
#url ⇒ Object
Returns the value of attribute url.
45 46 47 |
# File 'lib/artimis/camera.rb', line 45 def url @url end |
Class Method Details
.all ⇒ Object
10 11 12 |
# File 'lib/artimis/camera.rb', line 10 def all page.links_with(:href => /\/camera\//) end |
.find(params = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/artimis/camera.rb', line 14 def find(params = {}) if params[:description] cameras = [] page.links_with(:text => params[:description]).each do |link| camera_page = link.click cameras << new(camera_page, :url => link.href, :description => link.text) end cameras elsif params[:id] link = page.link_with(:href => /camera#{params[:id]}/) return nil unless link camera_page = link.click new(camera_page, :url => link.href, :description => link.text) end end |