Class: Threads::API::Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/threads/api/thread.rb

Defined Under Namespace

Classes: List

Instance Attribute Summary collapse

Instance Method Summary collapse

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"]

  @timestamp = json["timestamp"]
  @created_at = Time.iso8601(@timestamp) if @timestamp

  children = Array(json["children"])
  @children = children.map { |c| Thread.new(c) } if children.any?
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



17
18
19
# File 'lib/threads/api/thread.rb', line 17

def children
  @children
end

#created_atObject (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

#idObject (readonly)

Returns the value of attribute id.



17
18
19
# File 'lib/threads/api/thread.rb', line 17

def id
  @id
end

#media_urlObject (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

Returns the value of attribute permalink.



17
18
19
# File 'lib/threads/api/thread.rb', line 17

def permalink
  @permalink
end

#shortcodeObject (readonly)

Returns the value of attribute shortcode.



17
18
19
# File 'lib/threads/api/thread.rb', line 17

def shortcode
  @shortcode
end

#textObject (readonly)

Returns the value of attribute text.



17
18
19
# File 'lib/threads/api/thread.rb', line 17

def text
  @text
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



17
18
19
# File 'lib/threads/api/thread.rb', line 17

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



17
18
19
# File 'lib/threads/api/thread.rb', line 17

def type
  @type
end

#user_idObject (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

#usernameObject (readonly)

Returns the value of attribute username.



17
18
19
# File 'lib/threads/api/thread.rb', line 17

def username
  @username
end

#video_thumbnail_urlObject (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

Returns:

  • (Boolean)


38
39
40
# File 'lib/threads/api/thread.rb', line 38

def quote_post?
  @is_quote_post
end