tumblrb 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ module Tumblr
2
+ class Photo < Item
3
+ attr_accessor :caption, :sizes
4
+
5
+ class Size < Struct.new(:url, :max_width)
6
+ def as_json
7
+ {
8
+ :url => url,
9
+ :max_width => max_width
10
+ }
11
+ end
12
+ end
13
+
14
+ def max_size
15
+ sizes.last
16
+ end
17
+
18
+ def as_json
19
+ super.merge!({
20
+ :caption => caption,
21
+ :sizes => sizes.map { |size| size.as_json }
22
+ })
23
+ end
24
+
25
+ private
26
+
27
+ def parse_xml_node(node)
28
+ super(node)
29
+ self.caption = node.css('photo-caption').first.try(:content)
30
+ self.sizes = node.css("photo-url").collect do |size|
31
+ Size.new(size.content, size['max-width'].to_i)
32
+ end
33
+ self.sizes.sort! { |s1, s2| s1.max_width <=> s2.max_width }
34
+ self
35
+ end
36
+ end
37
+ end
@@ -1,4 +1,4 @@
1
1
  module Tumblr
2
2
  # The version of the gem
3
- VERSION = '1.0.4'.freeze unless defined?(::Twitter::VERSION)
3
+ VERSION = '1.0.5'.freeze unless defined?(::Twitter::VERSION)
4
4
  end
data/tumblrb.gemspec CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  "lib/tumblr/item.rb",
27
27
  "lib/tumblr/link.rb",
28
28
  "lib/tumblr/page.rb",
29
+ "lib/tumblr/photo.rb",
29
30
  "lib/tumblr/quote.rb",
30
31
  "lib/tumblr/regular.rb",
31
32
  "lib/tumblr/user.rb",
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: tumblrb
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.4
5
+ version: 1.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jesse Reiss
@@ -56,6 +56,7 @@ files:
56
56
  - lib/tumblr/item.rb
57
57
  - lib/tumblr/link.rb
58
58
  - lib/tumblr/page.rb
59
+ - lib/tumblr/photo.rb
59
60
  - lib/tumblr/quote.rb
60
61
  - lib/tumblr/regular.rb
61
62
  - lib/tumblr/user.rb