Class: Ruqqus::ItemBase Abstract
- Inherits:
-
Object
- Object
- Ruqqus::ItemBase
- Defined in:
- lib/ruqqus/types/item_base.rb
Overview
This class is abstract.
Base class for all all major API types.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#created ⇒ Time
readonly
The time the item was created.
-
#created_utc ⇒ Integer
readonly
The time the item was created, in seconds since the Unix epoch.
-
#id ⇒ String
readonly
A unique ID for this item.
-
#permalink ⇒ String
readonly
A relative link to this item.
Class Method Summary collapse
-
.from_json(json) ⇒ Object
Loads the object from a JSON-formatted string.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
true
if this object is equal to another, otherwisefalse
. -
#banned? ⇒ Boolean
true
if item has been banned, otherwisefalse
.
Instance Attribute Details
#created ⇒ Time (readonly)
Returns the time the item was created.
|
# File 'lib/ruqqus/types/item_base.rb', line 17
|
#created_utc ⇒ Integer (readonly)
Returns the time the item was created, in seconds since the Unix epoch.
|
# File 'lib/ruqqus/types/item_base.rb', line 13
|
#id ⇒ String (readonly)
Returns a unique ID for this item.
|
# File 'lib/ruqqus/types/item_base.rb', line 21
|
#permalink ⇒ String (readonly)
Returns a relative link to this item.
|
# File 'lib/ruqqus/types/item_base.rb', line 9
|
Class Method Details
.from_json(json) ⇒ Object
Loads the object from a JSON-formatted string.
59 60 61 62 63 64 |
# File 'lib/ruqqus/types/item_base.rb', line 59 def self.from_json(json) obj = allocate data = json.is_a?(Hash) ? json : JSON.parse(json, symbolize_names: true) obj.instance_variable_set(:@data, data) obj end |
Instance Method Details
#==(other) ⇒ Boolean
Returns true
if this object is equal to another, otherwise false
.
33 34 35 |
# File 'lib/ruqqus/types/item_base.rb', line 33 def ==(other) self.class == other.class && id == other.id end |
#banned? ⇒ Boolean
Returns true
if item has been banned, otherwise false
.
27 28 29 |
# File 'lib/ruqqus/types/item_base.rb', line 27 def banned? !!@data[:is_banned] end |