Class: Instagrammer::Post
- Inherits:
-
Object
- Object
- Instagrammer::Post
- Includes:
- Capybara::DSL, Utils
- Defined in:
- lib/instagrammer/post.rb
Instance Attribute Summary collapse
-
#image_url ⇒ Object
readonly
Returns the value of attribute image_url.
-
#image_urls ⇒ Object
readonly
Returns the value of attribute image_urls.
-
#shortcode ⇒ Object
readonly
Returns the value of attribute shortcode.
Instance Method Summary collapse
- #caption ⇒ Object
- #comment_count ⇒ Object
- #data ⇒ Object
-
#initialize(shortcode) ⇒ Post
constructor
A new instance of Post.
- #like_count ⇒ Object
- #photo? ⇒ Boolean
- #public? ⇒ Boolean
- #type ⇒ Object
- #upload_date ⇒ Object
- #user ⇒ Object
- #video? ⇒ Boolean
- #watch_count ⇒ Object
Methods included from Utils
Constructor Details
#initialize(shortcode) ⇒ Post
Returns a new instance of Post.
9 10 11 12 |
# File 'lib/instagrammer/post.rb', line 9 def initialize(shortcode) @shortcode = shortcode @data = nil end |
Instance Attribute Details
#image_url ⇒ Object (readonly)
Returns the value of attribute image_url.
7 8 9 |
# File 'lib/instagrammer/post.rb', line 7 def image_url @image_url end |
#image_urls ⇒ Object (readonly)
Returns the value of attribute image_urls.
7 8 9 |
# File 'lib/instagrammer/post.rb', line 7 def image_urls @image_urls end |
#shortcode ⇒ Object (readonly)
Returns the value of attribute shortcode.
7 8 9 |
# File 'lib/instagrammer/post.rb', line 7 def shortcode @shortcode end |
Instance Method Details
#caption ⇒ Object
46 47 48 |
# File 'lib/instagrammer/post.rb', line 46 def data["caption"] end |
#comment_count ⇒ Object
54 55 56 |
# File 'lib/instagrammer/post.rb', line 54 def comment_count data["commentCount"].to_i end |
#data ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/instagrammer/post.rb', line 19 def data get_data unless @data case @status when :private then raise Instagrammer::PrivatePost.new("Private post: #{@shortcode}") when :not_found then raise Instagrammer::PostNotFound.new("Post not found: #{@shortcode}") when :invalid then raise Instagrammer::PostInvalid.new("Post invalid: #{@shortcode}") else @data end end |
#like_count ⇒ Object
58 59 60 |
# File 'lib/instagrammer/post.rb', line 58 def like_count data["interactionStatistic"]["userInteractionCount"].to_i if photo? end |
#photo? ⇒ Boolean
34 35 36 |
# File 'lib/instagrammer/post.rb', line 34 def photo? type == :photo end |
#public? ⇒ Boolean
14 15 16 17 |
# File 'lib/instagrammer/post.rb', line 14 def public? get_data unless @data @status == :public end |
#type ⇒ Object
30 31 32 |
# File 'lib/instagrammer/post.rb', line 30 def type data["@type"] == "ImageObject" ? :photo : :video end |
#upload_date ⇒ Object
50 51 52 |
# File 'lib/instagrammer/post.rb', line 50 def upload_date DateTime.parse data["uploadDate"] end |
#user ⇒ Object
42 43 44 |
# File 'lib/instagrammer/post.rb', line 42 def user Instagrammer::User.new data["author"]["alternateName"] end |
#video? ⇒ Boolean
38 39 40 |
# File 'lib/instagrammer/post.rb', line 38 def video? type == :video end |
#watch_count ⇒ Object
62 63 64 |
# File 'lib/instagrammer/post.rb', line 62 def watch_count data["interactionStatistic"]["userInteractionCount"].to_i if video? end |