Class: Googletastic::Image
Constant Summary
Constants included from Mixins::Namespaces
Mixins::Namespaces::NAMESPACES
Instance Attribute Summary collapse
-
#access ⇒ Object
Returns the value of attribute access.
-
#album_id ⇒ Object
Returns the value of attribute album_id.
-
#commentable ⇒ Object
Returns the value of attribute commentable.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#height ⇒ Object
Returns the value of attribute height.
-
#id ⇒ Object
Returns the value of attribute id.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#size ⇒ Object
Returns the value of attribute size.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#thumbnails ⇒ Object
Returns the value of attribute thumbnails.
-
#title ⇒ Object
Returns the value of attribute title.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#url ⇒ Object
Returns the value of attribute url.
-
#width ⇒ Object
Returns the value of attribute width.
Attributes inherited from Base
#acl, #attachment_path, #etag, #head, #keep_raw, #raw, #response, #synced_with
Attributes included from Mixins::Attributes
Class Method Summary collapse
- .build_url(options) ⇒ Object
- .client_class ⇒ Object
- .index_url ⇒ Object
-
.marshall(record) ⇒ Object
not implemented.
- .unmarshall(xml) ⇒ Object
- .valid_access?(value) ⇒ Boolean
- .valid_image_max_size?(value) ⇒ Boolean
- .valid_kind?(value) ⇒ Boolean
- .valid_queries ⇒ Object
Methods inherited from Base
Methods included from Mixins::Pagination
Methods included from Mixins::Finders
Methods included from Mixins::Parsing
Methods included from Mixins::Requesting
Methods included from Mixins::Attributes
#attribute_names, #has_attribute?, #inspect
Methods included from Mixins::Namespaces
Constructor Details
This class inherits a constructor from Googletastic::Base
Instance Attribute Details
#access ⇒ Object
Returns the value of attribute access.
4 5 6 |
# File 'lib/googletastic/image.rb', line 4 def access @access end |
#album_id ⇒ Object
Returns the value of attribute album_id.
4 5 6 |
# File 'lib/googletastic/image.rb', line 4 def album_id @album_id end |
#commentable ⇒ Object
Returns the value of attribute commentable.
4 5 6 |
# File 'lib/googletastic/image.rb', line 4 def commentable @commentable end |
#content_type ⇒ Object
Returns the value of attribute content_type.
3 4 5 |
# File 'lib/googletastic/image.rb', line 3 def content_type @content_type end |
#created_at ⇒ Object
Returns the value of attribute created_at.
4 5 6 |
# File 'lib/googletastic/image.rb', line 4 def created_at @created_at end |
#height ⇒ Object
Returns the value of attribute height.
3 4 5 |
# File 'lib/googletastic/image.rb', line 3 def height @height end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/googletastic/image.rb', line 4 def id @id end |
#kind ⇒ Object
Returns the value of attribute kind.
4 5 6 |
# File 'lib/googletastic/image.rb', line 4 def kind @kind end |
#size ⇒ Object
Returns the value of attribute size.
3 4 5 |
# File 'lib/googletastic/image.rb', line 3 def size @size end |
#summary ⇒ Object
Returns the value of attribute summary.
3 4 5 |
# File 'lib/googletastic/image.rb', line 3 def summary @summary end |
#thumbnails ⇒ Object
Returns the value of attribute thumbnails.
3 4 5 |
# File 'lib/googletastic/image.rb', line 3 def thumbnails @thumbnails end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/googletastic/image.rb', line 3 def title @title end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
4 5 6 |
# File 'lib/googletastic/image.rb', line 4 def updated_at @updated_at end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/googletastic/image.rb', line 3 def url @url end |
#width ⇒ Object
Returns the value of attribute width.
3 4 5 |
# File 'lib/googletastic/image.rb', line 3 def width @width end |
Class Method Details
.build_url(options) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/googletastic/image.rb', line 41 def build_url() base = .has_key?(:url) ? [:url] : self.index_url [:url] = base [:kind] = "photo" unless .has_key?(:kind) [:access] ||= "all" #options[:image_max_size] = 720 unless options.has_key?(:image_max_size) super() end |
.client_class ⇒ Object
33 34 35 |
# File 'lib/googletastic/image.rb', line 33 def client_class "Photos" end |
.index_url ⇒ Object
37 38 39 |
# File 'lib/googletastic/image.rb', line 37 def index_url "http://picasaweb.google.com/data/feed/api/user/#{Googletastic.credentials[:username]}" end |
.marshall(record) ⇒ Object
not implemented
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/googletastic/image.rb', line 104 def marshall(record) Nokogiri::XML::Builder.new { |xml| xml.entry('xmlns' => Googletastic::ATOM_NS, 'xmlns:docs' => ns("docs")) { if record.id xml.id { xml.text show_url(record.id) } end xml.title { xml.text record.title } } }.to_xml end |
.unmarshall(xml) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/googletastic/image.rb', line 50 def unmarshall(xml) records = xml.xpath("//atom:entry", ns_tag("atom")).collect do |record| # thumbnails thumbnails = record.xpath("media:group/media:thumbnail").collect do |thumbnail| url = thumbnail["url"] width = thumbnail["width"].to_i height = thumbnail["height"].to_i Googletastic::Thumbnail.new( :url => url, :width => width, :height => height ) end id = record.xpath("atom:id", ns_tag("atom")).first.text created_at = record.xpath("atom:published", ns_tag("atom")).first.text updated_at = record.xpath("atom:updated", ns_tag("atom")).first.text kind = "photo" title = record.xpath("atom:title", ns_tag("atom")).first.text summary = record.xpath("atom:summary", ns_tag("atom")).first.text album_id = record.xpath("gphoto:albumid", ns_tag("gphoto")).first.text access = record.xpath("gphoto:access", ns_tag("gphoto")).first.text width = record.xpath("gphoto:width", ns_tag("gphoto")).first.text.to_i height = record.xpath("gphoto:height", ns_tag("gphoto")).first.text.to_i size = record.xpath("gphoto:size", ns_tag("gphoto")).first.text.to_i commentable = record.xpath("gphoto:commentingEnabled", ns_tag("gphoto")).first.text == "true" ? true : false content = record.xpath("media:group/media:content").first url = content["url"].to_s content_type = content["type"].to_s Googletastic::Image.new( :id => id, :created_at => created_at, :kind => kind, :title => title, :summary => summary, :album_id => album_id, :access => access, :width => width, :height => height, :size => size, :commentable => commentable, :url => url, :content_type => content_type, :thumbnails => thumbnails ) end records end |
.valid_access?(value) ⇒ Boolean
21 22 23 |
# File 'lib/googletastic/image.rb', line 21 def valid_access?(value) %w(all private public visible).include?(value) end |
.valid_image_max_size?(value) ⇒ Boolean
25 26 27 |
# File 'lib/googletastic/image.rb', line 25 def valid_image_max_size?(value) [94, 110, 128, 200, 220, 288, 320, 400, 512, 576, 640, 720, 800, 912, 1024, 1152, 1280, 1440, 1600].include?(value) end |
.valid_kind?(value) ⇒ Boolean
29 30 31 |
# File 'lib/googletastic/image.rb', line 29 def valid_kind?(value) %w(album photo comment tag user).include?(value) end |
.valid_queries ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/googletastic/image.rb', line 9 def valid_queries { :access => "access", :geo_coordinates => "bbox", :geo_location => "l", :image_max_size => "imgmax", :thumb_size => "thumbsize", :kind => "kind", :tag => "tag", }.merge(super) end |