Class: Redd::Thing

Inherits:
Base
  • Object
show all
Defined in:
lib/redd/thing.rb,
lib/redd/thing/editable.rb,
lib/redd/thing/hideable.rb,
lib/redd/thing/saveable.rb,
lib/redd/thing/voteable.rb,
lib/redd/thing/inboxable.rb,
lib/redd/thing/reportable.rb,
lib/redd/thing/messageable.rb,
lib/redd/thing/moderatable.rb

Overview

A reddit thing.

Defined Under Namespace

Modules: Editable, Hideable, Inboxable, Messageable, Moderatable, Reportable, Saveable, Voteable

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes, #client

Instance Method Summary collapse

Methods inherited from Base

#[], attr_reader, define_attribute_method, define_predicate_method, #initialize

Constructor Details

This class inherits a constructor from Redd::Base

Instance Attribute Details

#idString (readonly)

Returns The id value for the thing.

Returns:

  • (String)

    The id value for the thing.



9
10
11
# File 'lib/redd/thing.rb', line 9

def id
  @id
end

#kindString (readonly)

Returns The kind of the thing.

Returns:

  • (String)

    The kind of the thing.



13
14
15
# File 'lib/redd/thing.rb', line 13

def kind
  @kind
end

Instance Method Details

#==(other) ⇒ Boolean

Check for equality.

Parameters:

  • other

    The other object.

Returns:

  • (Boolean)


18
19
20
# File 'lib/redd/thing.rb', line 18

def ==(other)
  other.is_a?(Redd::Thing) && full_name == other.full_name
end

#fullnameString

Returns The fullname of the thing.

Returns:

  • (String)

    The fullname of the thing.



23
24
25
# File 'lib/redd/thing.rb', line 23

def fullname
  @fullname ||= (attributes[:name] || "#{kind}_#{id}")
end