Class: RedditKit::Thing

Inherits:
Base
  • Object
show all
Defined in:
lib/redditkit/thing.rb

Overview

A base class for objects which have both a kind and an identifier.

Direct Known Subclasses

Comment, Link, ModeratorAction, PrivateMessage, Subreddit, User

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes

Instance Method Summary collapse

Methods inherited from Base

#[], attr_reader, #initialize

Constructor Details

This class inherits a constructor from RedditKit::Base

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/redditkit/thing.rb', line 8

def id
  @id
end

#kindObject (readonly)

Returns the value of attribute kind.



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

def kind
  @kind
end

Instance Method Details

#==(other) ⇒ Object



11
12
13
14
# File 'lib/redditkit/thing.rb', line 11

def ==(other)
  return false unless other.is_a?(Thing)
  full_name == other.full_name
end

#full_nameObject

Returns the object’s full name.



17
18
19
# File 'lib/redditkit/thing.rb', line 17

def full_name
  @full_name ||= "#{kind}_#{id}"
end