Class: Model
- Inherits:
-
Object
- Object
- Model
- Defined in:
- lib/reddit.rb
Instance Attribute Summary collapse
-
#filter_results ⇒ Object
readonly
Returns the value of attribute filter_results.
Instance Method Summary collapse
- #get_funny_image_from_reddit ⇒ Object
- #get_image_punch_line ⇒ Object
- #get_joke_from_reddit ⇒ Object
- #get_punch_line_from_reddit ⇒ Object
-
#initialize ⇒ Model
constructor
A new instance of Model.
Constructor Details
#initialize ⇒ Model
Returns a new instance of Model.
7 8 9 10 11 12 |
# File 'lib/reddit.rb', line 7 def initialize @info_funny = Reddit::Api.new "user", "pa1sword" @info_results = Reddit::Api.new "user", "pa1sword" @funny = @info_funny.browse "funny" @results = @info_results.browse "jokes" end |
Instance Attribute Details
#filter_results ⇒ Object (readonly)
Returns the value of attribute filter_results.
5 6 7 |
# File 'lib/reddit.rb', line 5 def filter_results @filter_results end |
Instance Method Details
#get_funny_image_from_reddit ⇒ Object
25 26 27 28 |
# File 'lib/reddit.rb', line 25 def get_funny_image_from_reddit @image = @funny.shuffle.first @image.url end |
#get_image_punch_line ⇒ Object
30 31 32 |
# File 'lib/reddit.rb', line 30 def get_image_punch_line @image.title end |
#get_joke_from_reddit ⇒ Object
15 16 17 18 19 |
# File 'lib/reddit.rb', line 15 def get_joke_from_reddit @current_joke = @results.shuffle.first # get_joke_from_reddit if @current_joke.selftext.length > 50 @current_joke.title end |
#get_punch_line_from_reddit ⇒ Object
21 22 23 |
# File 'lib/reddit.rb', line 21 def get_punch_line_from_reddit @current_joke.selftext end |