Class: CureLine::Post

Inherits:
Mash
  • Object
show all
Includes:
ResourceMethods, TimeMethods
Defined in:
lib/cure_line/post.rb

Instance Method Summary collapse

Methods included from ResourceMethods

#resource_url

Methods included from TimeMethods

#time_at

Instance Method Details

#created_timeActiveSupport::TimeWithZone, Time

Returns:

  • (ActiveSupport::TimeWithZone)

    When ‘Time.zone` is initialized

  • (Time)

    When ‘Time.zone` is not initialized or without activesupport



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

#mediasArray<Hash>

Returns:

  • (Array<Hash>)


48
49
50
# File 'lib/cure_line/post.rb', line 48

def medias
  dig("post", "contents", "media") || []
end

#nicknameString

Returns:

  • (String)


7
8
9
# File 'lib/cure_line/post.rb', line 7

def nickname
  dig("post", "userInfo", "nickname")
end

#photo_urlsArray<String>

Returns:

  • (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_urlString

Returns:

  • (String)


12
13
14
# File 'lib/cure_line/post.rb', line 12

def picture_url
  dig("post", "userInfo", "pictureUrl")
end

#post_urlString

Returns:

  • (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

#textString

Returns:

  • (String)


24
25
26
# File 'lib/cure_line/post.rb', line 24

def text
  dig("post", "contents", "text")
end

#updated_timeActiveSupport::TimeWithZone, Time

Returns:

  • (ActiveSupport::TimeWithZone)

    When ‘Time.zone` is initialized

  • (Time)

    When ‘Time.zone` is not initialized or without activesupport



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