Class: Pocket::Article
- Inherits:
-
Object
- Object
- Pocket::Article
- Defined in:
- lib/pocket/article.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #article? ⇒ Boolean
- #excerpt ⇒ Object
- #favorite? ⇒ Boolean
- #favorited? ⇒ Boolean
- #given_title ⇒ Object
- #given_url ⇒ Object
- #has_image? ⇒ Boolean
- #has_video? ⇒ Boolean
- #image? ⇒ Boolean
-
#initialize(response) ⇒ Article
constructor
A new instance of Article.
- #item_id ⇒ Object
- #read? ⇒ Boolean
- #read_url ⇒ Object
- #resolved_id ⇒ Object
- #resolved_title ⇒ Object
- #resolved_url ⇒ Object
- #status ⇒ Object
- #thumbnail ⇒ Object
- #time_added ⇒ Object
- #time_favorited ⇒ Object
- #time_read ⇒ Object
- #time_updated ⇒ Object
- #video? ⇒ Boolean
- #word_count ⇒ Object
Constructor Details
#initialize(response) ⇒ Article
Returns a new instance of Article.
7 8 9 |
# File 'lib/pocket/article.rb', line 7 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/pocket/article.rb', line 5 def response @response end |
Instance Method Details
#article? ⇒ Boolean
43 44 45 |
# File 'lib/pocket/article.rb', line 43 def article? Integer(parsed_response.fetch("is_article")) == 1 end |
#excerpt ⇒ Object
39 40 41 |
# File 'lib/pocket/article.rb', line 39 def excerpt parsed_response.fetch("excerpt") end |
#favorite? ⇒ Boolean
31 32 33 |
# File 'lib/pocket/article.rb', line 31 def favorite? Integer(parsed_response.fetch("favorite")) == 1 end |
#favorited? ⇒ Boolean
90 91 92 |
# File 'lib/pocket/article.rb', line 90 def favorited? Integer(parsed_response["time_favorited"]) > 0 end |
#given_title ⇒ Object
23 24 25 |
# File 'lib/pocket/article.rb', line 23 def given_title parsed_response.fetch("given_title") end |
#given_url ⇒ Object
15 16 17 |
# File 'lib/pocket/article.rb', line 15 def given_url parsed_response.fetch("given_url") end |
#has_image? ⇒ Boolean
47 48 49 |
# File 'lib/pocket/article.rb', line 47 def has_image? Integer(parsed_response.fetch("has_image")) == 1 end |
#has_video? ⇒ Boolean
55 56 57 |
# File 'lib/pocket/article.rb', line 55 def has_video? Integer(parsed_response.fetch("has_video")) == 1 end |
#image? ⇒ Boolean
51 52 53 |
# File 'lib/pocket/article.rb', line 51 def image? Integer(parsed_response.fetch("has_image")) == 2 end |
#item_id ⇒ Object
11 12 13 |
# File 'lib/pocket/article.rb', line 11 def item_id Integer(parsed_response.fetch("item_id")) end |
#read? ⇒ Boolean
99 100 101 |
# File 'lib/pocket/article.rb', line 99 def read? Integer(parsed_response["time_read"]) > 0 end |
#read_url ⇒ Object
103 104 105 |
# File 'lib/pocket/article.rb', line 103 def read_url "https://getpocket.com/read/#{item_id}" end |
#resolved_id ⇒ Object
67 68 69 |
# File 'lib/pocket/article.rb', line 67 def resolved_id Integer(parsed_response.fetch("resolved_id")) end |
#resolved_title ⇒ Object
27 28 29 |
# File 'lib/pocket/article.rb', line 27 def resolved_title parsed_response.fetch("resolved_title") end |
#resolved_url ⇒ Object
19 20 21 |
# File 'lib/pocket/article.rb', line 19 def resolved_url parsed_response.fetch("resolved_url") end |
#status ⇒ Object
35 36 37 |
# File 'lib/pocket/article.rb', line 35 def status Integer(parsed_response.fetch("status")) end |
#thumbnail ⇒ Object
71 72 73 |
# File 'lib/pocket/article.rb', line 71 def thumbnail parsed_response.fetch("top_image_url", "") end |
#time_added ⇒ Object
75 76 77 78 |
# File 'lib/pocket/article.rb', line 75 def time_added return nil unless parsed_response["time_added"] Time.at(Integer(parsed_response["time_added"])) end |
#time_favorited ⇒ Object
94 95 96 97 |
# File 'lib/pocket/article.rb', line 94 def time_favorited return nil unless parsed_response["time_favorited"] Time.at(Integer(parsed_response["time_favorited"])) end |
#time_read ⇒ Object
85 86 87 88 |
# File 'lib/pocket/article.rb', line 85 def time_read return nil unless parsed_response["time_read"] Time.at(Integer(parsed_response["time_read"])) end |
#time_updated ⇒ Object
80 81 82 83 |
# File 'lib/pocket/article.rb', line 80 def time_updated return nil unless parsed_response["time_updated"] Time.at(Integer(parsed_response["time_updated"])) end |
#video? ⇒ Boolean
59 60 61 |
# File 'lib/pocket/article.rb', line 59 def video? Integer(parsed_response.fetch("has_video")) == 2 end |
#word_count ⇒ Object
63 64 65 |
# File 'lib/pocket/article.rb', line 63 def word_count Integer(parsed_response.fetch("word_count")) end |