Class: CureLine::Post
- Includes:
- ResourceMethods, TimeMethods
- Defined in:
- lib/cure_line/post.rb
Instance Method Summary collapse
- #created_time ⇒ ActiveSupport::TimeWithZone, Time
- #medias ⇒ Array<Hash>
- #nickname ⇒ String
- #photo_urls ⇒ Array<String>
- #picture_url ⇒ String
- #post_url ⇒ String
- #text ⇒ String
- #updated_time ⇒ ActiveSupport::TimeWithZone, Time
Methods included from ResourceMethods
Methods included from TimeMethods
Instance Method Details
#created_time ⇒ ActiveSupport::TimeWithZone, Time
30 31 32 33 |
# File 'lib/cure_line/post.rb', line 30 def created_time millisec = dig("post", "postInfo", "createdTime") time_at(millisec / 1000) end |
#medias ⇒ Array<Hash>
48 49 50 |
# File 'lib/cure_line/post.rb', line 48 def medias dig("post", "contents", "media") || [] end |
#nickname ⇒ String
7 8 9 |
# File 'lib/cure_line/post.rb', line 7 def nickname dig("post", "userInfo", "nickname") end |
#photo_urls ⇒ Array<String>
43 44 45 |
# File 'lib/cure_line/post.rb', line 43 def photo_urls medias.select { |media| media["type"] == "PHOTO" }.map { |media| resource_url(media["resourceId"]) } end |
#picture_url ⇒ String
12 13 14 |
# File 'lib/cure_line/post.rb', line 12 def picture_url dig("post", "userInfo", "pictureUrl") end |
#post_url ⇒ String
17 18 19 20 21 |
# File 'lib/cure_line/post.rb', line 17 def post_url home_id = dig("post", "postInfo", "homeId") post_id = dig("post", "postInfo", "postId") "https://timeline.line.me/post/#{home_id}/#{post_id}" end |
#text ⇒ String
24 25 26 |
# File 'lib/cure_line/post.rb', line 24 def text dig("post", "contents", "text") end |
#updated_time ⇒ ActiveSupport::TimeWithZone, Time
37 38 39 40 |
# File 'lib/cure_line/post.rb', line 37 def updated_time millisec = dig("post", "postInfo", "updatedTime") time_at(millisec / 1000) end |