Class: Reddit::Message
- Includes:
- JsonListing
- Defined in:
- lib/ruby_reddit_api/message.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#body_html ⇒ Object
readonly
Returns the value of attribute body_html.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#created_utc ⇒ Object
readonly
Returns the value of attribute created_utc.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#dest ⇒ Object
readonly
Returns the value of attribute dest.
-
#first_message ⇒ Object
readonly
Returns the value of attribute first_message.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent_id ⇒ Object
readonly
Returns the value of attribute parent_id.
-
#replies ⇒ Object
readonly
Returns the value of attribute replies.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#subreddit ⇒ Object
readonly
Returns the value of attribute subreddit.
-
#was_comment ⇒ Object
readonly
Returns the value of attribute was_comment.
Attributes inherited from Base
Instance Method Summary collapse
-
#author ⇒ Reddit::User
The author of the message.
-
#id ⇒ String
The reddit ID of this message.
-
#initialize(json) ⇒ Message
constructor
A new instance of Message.
- #inspect ⇒ Object
-
#short_body ⇒ String
Trimmed comment body suitable for #inspect.
Methods included from JsonListing
Methods inherited from Base
base_headers, #base_headers, #cookie, #logged_in?, #login, #logout, #modhash, #read, #user, #user_agent, user_agent, #user_id
Constructor Details
#initialize(json) ⇒ Message
Returns a new instance of Message.
7 8 9 10 |
# File 'lib/ruby_reddit_api/message.rb', line 7 def initialize(json) parse(json) @debug = StringIO.new end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def body @body end |
#body_html ⇒ Object (readonly)
Returns the value of attribute body_html.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def body_html @body_html end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def context @context end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def created @created end |
#created_utc ⇒ Object (readonly)
Returns the value of attribute created_utc.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def created_utc @created_utc end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def debug @debug end |
#dest ⇒ Object (readonly)
Returns the value of attribute dest.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def dest @dest end |
#first_message ⇒ Object (readonly)
Returns the value of attribute first_message.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def @first_message end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def name @name end |
#parent_id ⇒ Object (readonly)
Returns the value of attribute parent_id.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def parent_id @parent_id end |
#replies ⇒ Object (readonly)
Returns the value of attribute replies.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def replies @replies end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def subject @subject end |
#subreddit ⇒ Object (readonly)
Returns the value of attribute subreddit.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def subreddit @subreddit end |
#was_comment ⇒ Object (readonly)
Returns the value of attribute was_comment.
6 7 8 |
# File 'lib/ruby_reddit_api/message.rb', line 6 def was_comment @was_comment end |
Instance Method Details
#author ⇒ Reddit::User
The author of the message. The data is lazy-loaded and cached on the message
20 21 22 |
# File 'lib/ruby_reddit_api/message.rb', line 20 def @author_data ||= read("/user/#{@author}/about.json", :handler => "User") end |
#id ⇒ String
The reddit ID of this message
14 15 16 |
# File 'lib/ruby_reddit_api/message.rb', line 14 def id "#{kind}_#{@id}" end |
#inspect ⇒ Object
24 25 26 |
# File 'lib/ruby_reddit_api/message.rb', line 24 def inspect "<Reddit::Message '#{short_body}'>" end |
#short_body ⇒ String
Trimmed comment body suitable for #inspect
30 31 32 33 34 35 36 |
# File 'lib/ruby_reddit_api/message.rb', line 30 def short_body if body.size > 15 body[0..15] else body end end |