Class: Threads::API::Thread
- Inherits:
-
Object
- Object
- Threads::API::Thread
- Defined in:
- lib/threads/api/thread.rb
Defined Under Namespace
Classes: List
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#media_url ⇒ Object
readonly
Returns the value of attribute media_url.
-
#permalink ⇒ Object
readonly
Returns the value of attribute permalink.
-
#shortcode ⇒ Object
readonly
Returns the value of attribute shortcode.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#video_thumbnail_url ⇒ Object
readonly
Returns the value of attribute video_thumbnail_url.
Instance Method Summary collapse
-
#initialize(json) ⇒ Thread
constructor
A new instance of Thread.
- #quote_post? ⇒ Boolean
Constructor Details
#initialize(json) ⇒ Thread
Returns a new instance of Thread.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/threads/api/thread.rb', line 19 def initialize(json) @id = json["id"] @type = json["media_type"] @permalink = json["permalink"] @shortcode = json["shortcode"] @text = json["text"] @media_url = json["media_url"] @video_thumbnail_url = json["thumbnail_url"] @user_id = json.dig("owner", "id") @username = json["username"] @is_quote_post = json["is_quote_post"] = json["timestamp"] @created_at = Time.iso8601() if children = Array(json["children"]) @children = children.map { |c| Thread.new(c) } if children.any? end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
17 18 19 |
# File 'lib/threads/api/thread.rb', line 17 def children @children end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
17 18 19 |
# File 'lib/threads/api/thread.rb', line 17 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
17 18 19 |
# File 'lib/threads/api/thread.rb', line 17 def id @id end |
#media_url ⇒ Object (readonly)
Returns the value of attribute media_url.
17 18 19 |
# File 'lib/threads/api/thread.rb', line 17 def media_url @media_url end |
#permalink ⇒ Object (readonly)
Returns the value of attribute permalink.
17 18 19 |
# File 'lib/threads/api/thread.rb', line 17 def permalink @permalink end |
#shortcode ⇒ Object (readonly)
Returns the value of attribute shortcode.
17 18 19 |
# File 'lib/threads/api/thread.rb', line 17 def shortcode @shortcode end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
17 18 19 |
# File 'lib/threads/api/thread.rb', line 17 def text @text end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
17 18 19 |
# File 'lib/threads/api/thread.rb', line 17 def end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
17 18 19 |
# File 'lib/threads/api/thread.rb', line 17 def type @type end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
17 18 19 |
# File 'lib/threads/api/thread.rb', line 17 def user_id @user_id end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
17 18 19 |
# File 'lib/threads/api/thread.rb', line 17 def username @username end |
#video_thumbnail_url ⇒ Object (readonly)
Returns the value of attribute video_thumbnail_url.
17 18 19 |
# File 'lib/threads/api/thread.rb', line 17 def video_thumbnail_url @video_thumbnail_url end |
Instance Method Details
#quote_post? ⇒ Boolean
38 39 40 |
# File 'lib/threads/api/thread.rb', line 38 def quote_post? @is_quote_post end |