Class: ReadIt::Sub
- Inherits:
-
Object
- Object
- ReadIt::Sub
- Defined in:
- lib/read_it/sub.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ Sub
constructor
A new instance of Sub.
- #recent ⇒ Object
- #recent_images ⇒ Object
- #sample ⇒ Object
Constructor Details
#initialize(name) ⇒ Sub
Returns a new instance of Sub.
5 6 7 |
# File 'lib/read_it/sub.rb', line 5 def initialize name @name = "/r/#{name}" end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/read_it/sub.rb', line 3 def name @name end |
Instance Method Details
#recent ⇒ Object
9 10 11 |
# File 'lib/read_it/sub.rb', line 9 def recent Post.parse ReadIt.http.get "#{name}/new.json" end |
#recent_images ⇒ Object
13 14 15 |
# File 'lib/read_it/sub.rb', line 13 def recent_images recent.select(&:image?) end |
#sample ⇒ Object
17 18 19 |
# File 'lib/read_it/sub.rb', line 17 def sample recent.sample end |