Class: Ruqqus::Submission Abstract

Inherits:
ItemBase show all
Defined in:
lib/ruqqus/types/submission.rb

Overview

This class is abstract.

Base class for Post and Comment types.

Direct Known Subclasses

Comment, Post

Instance Attribute Summary collapse

Attributes inherited from ItemBase

#created, #created_utc, #id, #permalink

Instance Method Summary collapse

Methods inherited from ItemBase

#==, #banned?, from_json

Instance Attribute Details

#author_nameString? (readonly)

Returns the name of the creator of the item, or nil if deleted account.

Returns:

  • (String?)

    the name of the creator of the item, or nil if deleted account.



# File 'lib/ruqqus/types/submission.rb', line 13

#bodyString (readonly)

Returns the text body of the item.

Returns:

  • (String)

    the text body of the item.



# File 'lib/ruqqus/types/submission.rb', line 17

#body_htmlString (readonly)

Returns the text body of the item in HTML format.

Returns:

  • (String)

    the text body of the item in HTML format.



# File 'lib/ruqqus/types/submission.rb', line 21

#downvotesInteger (readonly)

Returns the number of downvotes this item has received.

Returns:

  • (Integer)

    the number of downvotes this item has received.



# File 'lib/ruqqus/types/submission.rb', line 37

#fullnameString (readonly)

Returns the full ID of this item.

Returns:

  • (String)

    the full ID of this item.



# File 'lib/ruqqus/types/submission.rb', line 45

#guild_nameString (readonly)

Returns the name of the guild this item is contained within.

Returns:

  • (String)

    the name of the guild this item is contained within.



# File 'lib/ruqqus/types/submission.rb', line 49

#last_editTime (readonly)

Returns the time of the last edit.

Returns:

  • (Time)

    the time of the last edit.



# File 'lib/ruqqus/types/submission.rb', line 29

#last_edit_utcInteger (readonly)

Returns the time of the last edit in seconds since the Unix epoch, or 0 if never edited.

Returns:

  • (Integer)

    the time of the last edit in seconds since the Unix epoch, or 0 if never edited.



# File 'lib/ruqqus/types/submission.rb', line 25

#scoreInteger (readonly)

Returns a score calculated by adding upvotes and subtracting downvotes.

Returns:

  • (Integer)

    a score calculated by adding upvotes and subtracting downvotes.



# File 'lib/ruqqus/types/submission.rb', line 41

#titleString (readonly)

Returns the name/title of this item.

Returns:

  • (String)

    the name/title of this item.



# File 'lib/ruqqus/types/submission.rb', line 9

#upvotesInteger (readonly)

Returns the number of upvotes this item has received.

Returns:

  • (Integer)

    the number of upvotes this item has received.



# File 'lib/ruqqus/types/submission.rb', line 33

Instance Method Details

#archived?Boolean

Returns true if item has been archived, otherwise false.

Returns:

  • (Boolean)

    true if item has been archived, otherwise false.



73
74
75
# File 'lib/ruqqus/types/submission.rb', line 73

def archived?
  !!@data[:is_archived]
end

#deleted?Boolean

Returns true if item has been deleted, otherwise false.

Returns:

  • (Boolean)

    true if item has been deleted, otherwise false.



79
80
81
# File 'lib/ruqqus/types/submission.rb', line 79

def deleted?
  !!@data[:is_deleted]
end

#edited?Boolean

Returns true if post has been edited, otherwise false.

Returns:

  • (Boolean)

    true if post has been edited, otherwise false.



55
56
57
# File 'lib/ruqqus/types/submission.rb', line 55

def edited?
  @data[:edited_utc] != 0
end

#nsfl?Boolean

Returns true if item is adult content and flagged as NSFL, otheriwse false.

Returns:

  • (Boolean)

    true if item is adult content and flagged as NSFL, otheriwse false.



67
68
69
# File 'lib/ruqqus/types/submission.rb', line 67

def nsfl?
  !!@data[:is_nsfl]
end

#nsfw?Boolean

Returns true if item is adult content and flagged as NSFW, otherwise false.

Returns:

  • (Boolean)

    true if item is adult content and flagged as NSFW, otherwise false.



61
62
63
# File 'lib/ruqqus/types/submission.rb', line 61

def nsfw?
  !!@data[:is_nsfw]
end

#offensive?Boolean

Returns true if item has been classified has offensive, otherwise false.

Returns:

  • (Boolean)

    true if item has been classified has offensive, otherwise false.



85
86
87
# File 'lib/ruqqus/types/submission.rb', line 85

def offensive?
  !!@data[:is_offensive]
end

#to_sString

Returns the string representation of the object.

Returns:

  • (String)

    the string representation of the object.



91
92
93
# File 'lib/ruqqus/types/submission.rb', line 91

def to_s
  @data[:id]
end