Class: Hermaeus::Apocryphon
- Inherits:
-
Object
- Object
- Hermaeus::Apocryphon
- Defined in:
- lib/hermaeus/apocryphon.rb
Overview
Public: Data structure describing a Compendium entry.
Instance Method Summary collapse
-
#html ⇒ Object
Public: Accessor for the Apocryphon’s HTML as compiled by reddit.
-
#initialize(data) ⇒ Apocryphon
constructor
Public: Constructs an Apocryphon from reddit data responses.
-
#method_missing(name, *args, &block) ⇒ Object
Public: Permit method-style access to the underlying data Hash’s keys.
-
#text ⇒ Object
Public: Accessor for the Apocryphon’s Markdown text.
-
#to_s ⇒ Object
Public: Serializes the Apocryphon item to a string.
Constructor Details
#initialize(data) ⇒ Apocryphon
Public: Constructs an Apocryphon from reddit data responses.
data - A Hash emitted by Client#get_posts
7 8 9 |
# File 'lib/hermaeus/apocryphon.rb', line 7 def initialize data @data = data end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
Public: Permit method-style access to the underlying data Hash’s keys.
19 20 21 |
# File 'lib/hermaeus/apocryphon.rb', line 19 def method_missing name, *args, &block @data[name.to_sym] end |
Instance Method Details
#html ⇒ Object
Public: Accessor for the Apocryphon’s HTML as compiled by reddit.
29 30 31 |
# File 'lib/hermaeus/apocryphon.rb', line 29 def html data[:selftext_html] end |
#text ⇒ Object
Public: Accessor for the Apocryphon’s Markdown text.
24 25 26 |
# File 'lib/hermaeus/apocryphon.rb', line 24 def text @data[:selftext] end |
#to_s ⇒ Object
Public: Serializes the Apocryphon item to a string.
Returns a String containing the title and author.
14 15 16 |
# File 'lib/hermaeus/apocryphon.rb', line 14 def to_s "#{self.title} – by #{self.}" end |