Class: Redd::Models::LiveThread

Inherits:
Model
  • Object
show all
Defined in:
lib/redd/models/live_thread.rb

Overview

Represents a live thread.

Instance Attribute Summary collapse

Attributes inherited from Model

#client

Instance Method Summary collapse

Methods inherited from Model

#initialize

Constructor Details

This class inherits a constructor from Redd::Models::Model

Instance Attribute Details

#created_atString (readonly)

Returns the live thread creation time.

Returns:

  • (String)

    the live thread creation time


96
# File 'lib/redd/models/live_thread.rb', line 96

property :created_at, from: :created_utc, with: ->(t) { Time.at(t) }

#descriptionString (readonly)

Returns the live thread description.

Returns:

  • (String)

    the live thread description


84
# File 'lib/redd/models/live_thread.rb', line 84

property :description

#description_htmlString (readonly)

Returns the html-rendered thread description.

Returns:

  • (String)

    the html-rendered thread description


88
# File 'lib/redd/models/live_thread.rb', line 88

property :description_html

#idString (readonly)

Returns the thread id.

Returns:

  • (String)

    the thread id


76
# File 'lib/redd/models/live_thread.rb', line 76

property :id, :required

#nameString (readonly)

Returns the thread fullname.

Returns:

  • (String)

    the thread fullname


80
# File 'lib/redd/models/live_thread.rb', line 80

property :name, default: ->() { "LiveUpdateEvent_#{read_attribute(:id)}" }

#nsfw?Boolean (readonly)

Returns whether the thread is nsfw.

Returns:

  • (Boolean)

    whether the thread is nsfw


108
# File 'lib/redd/models/live_thread.rb', line 108

property :nsfw?, from: :nsfw

#resourcesString (readonly)

Returns the thread's resources section.

Returns:

  • (String)

    the thread's resources section


120
# File 'lib/redd/models/live_thread.rb', line 120

property :resources

#resources_htmlString (readonly)

Returns the html-rendered thread resources.

Returns:

  • (String)

    the html-rendered thread resources


124
# File 'lib/redd/models/live_thread.rb', line 124

property :resources_html

#stateString (readonly)

Returns the thread state (e.g. “live”).

Returns:

  • (String)

    the thread state (e.g. “live”)


104
# File 'lib/redd/models/live_thread.rb', line 104

property :state

#titleString (readonly)

Returns the live thread title.

Returns:

  • (String)

    the live thread title


92
# File 'lib/redd/models/live_thread.rb', line 92

property :title

#viewer_countInteger (readonly)

Returns the thread viewer count.

Returns:

  • (Integer)

    the thread viewer count


112
# File 'lib/redd/models/live_thread.rb', line 112

property :viewer_count

#viewer_count_fuzzed?Boolean (readonly)

Returns whether the viewer count is fuzzed.

Returns:

  • (Boolean)

    whether the viewer count is fuzzed


116
# File 'lib/redd/models/live_thread.rb', line 116

property :viewer_count_fuzzed?, from: :viewer_count_fuzzed

#websocket_urlString (readonly)

Returns the websocket url for listening to updates.

Returns:

  • (String)

    the websocket url for listening to updates


100
# File 'lib/redd/models/live_thread.rb', line 100

property :websocket_url

Instance Method Details

#configure(**params) ⇒ Object

Configure the settings of this live thread

Parameters:

  • params (Hash)

    a list of params to send with the request

Options Hash (**params):

  • :description (String)

    the new description

  • :nsfw (Boolean)

    whether the thread is for users 18 and above

  • :resources (String)

    the new resources

  • :title (String)

    the thread title


26
27
28
# File 'lib/redd/models/live_thread.rb', line 26

def configure(**params)
  client.post("/api/live/#{read_attribute(:id)}/edit", params)
end

#contributorsArray<User>

Returns the contributors to this thread.

Returns:

  • (Array<User>)

    the contributors to this thread


49
50
51
52
53
# File 'lib/redd/models/live_thread.rb', line 49

def contributors
  client.get("/live/#{read_attribute(:id)}/contributors").body[0][:data].map do |user|
    User.new(client, user)
  end
end

#delete_update(live_update) ⇒ Object

Delete a live thread update.

Parameters:

  • live_update (LiveUpdate)

    the update to strike out


44
45
46
# File 'lib/redd/models/live_thread.rb', line 44

def delete_update(live_update)
  client.post("/api/live/#{read_attribute(:id)}/delete_update", id: live_update.name)
end

#discussions(**params) ⇒ Listing<Submission>

Returns all discussions that link to this live thread.

Parameters:

  • params (Hash)

    a list of params to send with the request

Options Hash (**params):

  • :after (String)

    return results after the given fullname

  • :before (String)

    return results before the given fullname

  • :count (Integer)

    the number of items already seen in the listing

  • :limit (1..100)

    the maximum number of things to return

Returns:


70
71
72
# File 'lib/redd/models/live_thread.rb', line 70

def discussions(**params)
  client.model(:get, "/live/#{read_attribute(:id)}/discussions", params)
end

#invited_contributorsArray<User>

Returns users invited to contribute to this thread.

Returns:

  • (Array<User>)

    users invited to contribute to this thread


56
57
58
59
60
# File 'lib/redd/models/live_thread.rb', line 56

def invited_contributors
  client.get("/live/#{read_attribute(:id)}/contributors").body[1][:data].map do |user|
    User.new(client, user)
  end
end

#strike_update(live_update) ⇒ Object

Strike out a live thread update.

Parameters:

  • live_update (LiveUpdate)

    the update to strike out


38
39
40
# File 'lib/redd/models/live_thread.rb', line 38

def strike_update(live_update)
  client.post("/api/live/#{read_attribute(:id)}/strike_update", id: live_update.name)
end

#update(body) ⇒ Object

Add an update to this live event.

Parameters:

  • body (String)

    the update text


32
33
34
# File 'lib/redd/models/live_thread.rb', line 32

def update(body)
  client.post("/api/live/#{read_attribute(:id)}/update", body: body)
end

#updates(**params) ⇒ Listing

Get the updates from the thread.

Parameters:

  • params (Hash)

    a list of params to send with the request

Options Hash (**params):

  • :after (String)

    return results after the given fullname

  • :before (String)

    return results before the given fullname

  • :count (Integer)

    the number of items already seen in the listing

  • :limit (1..100)

    the maximum number of things to return

Returns:


16
17
18
# File 'lib/redd/models/live_thread.rb', line 16

def updates(**params)
  client.model(:get, "/live/#{read_attribute(:id)}", params)
end