class Ruqqus::ItemBase

@abstract Base class for all all major API types.

Public Class Methods

from_json(json) click to toggle source

Loads the object from a JSON-formatted string.

@param json [String,Hash] a JSON string representing the object.

@return [Object] the loaded object.

# 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

Public Instance Methods

==(other) click to toggle source

@return [Boolean] `true` if this object is equal to another, otherwise `false`.

# File lib/ruqqus/types/item_base.rb, line 33
def ==(other)
  self.class == other.class && id == other.id
end
banned?() click to toggle source

@return [Boolean] `true` if item has been banned, otherwise `false`.

# File lib/ruqqus/types/item_base.rb, line 27
def banned?
  !!@data[:is_banned]
end
created() click to toggle source
# File lib/ruqqus/types/item_base.rb, line 41
def created
  Time.at(created_utc)
end
created_utc() click to toggle source
# File lib/ruqqus/types/item_base.rb, line 37
def created_utc
  @data[:created_utc]
end
id() click to toggle source
# File lib/ruqqus/types/item_base.rb, line 45
def id
  @data[:id]
end