Class: RedditApi::Query
- Inherits:
-
Object
- Object
- RedditApi::Query
- Defined in:
- lib/reddit_api/query.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#offset_id ⇒ Object
readonly
Returns the value of attribute offset_id.
-
#resource_type ⇒ Object
readonly
Returns the value of attribute resource_type.
Instance Method Summary collapse
- #add_records(new_records) ⇒ Object
- #capture_count ⇒ Object
- #captured_records ⇒ Object
-
#initialize(args = {}) ⇒ Query
constructor
A new instance of Query.
Constructor Details
#initialize(args = {}) ⇒ Query
Returns a new instance of Query.
7 8 9 10 11 12 13 |
# File 'lib/reddit_api/query.rb', line 7 def initialize(args = {}) @count = args.fetch(:count) @endpoint = args.fetch(:endpoint, "") @offset_id = args.fetch(:offset, "") @records = args.fetch(:records, {}) @resource_type = args.fetch(:resource, "") end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
5 6 7 |
# File 'lib/reddit_api/query.rb', line 5 def count @count end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
5 6 7 |
# File 'lib/reddit_api/query.rb', line 5 def endpoint @endpoint end |
#offset_id ⇒ Object
Returns the value of attribute offset_id.
5 6 7 |
# File 'lib/reddit_api/query.rb', line 5 def offset_id @offset_id end |
#resource_type ⇒ Object (readonly)
Returns the value of attribute resource_type.
5 6 7 |
# File 'lib/reddit_api/query.rb', line 5 def resource_type @resource_type end |
Instance Method Details
#add_records(new_records) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/reddit_api/query.rb', line 15 def add_records(new_records) if count > 1 add_multiple_records(new_records) else add_single_record(new_records) end end |
#capture_count ⇒ Object
27 28 29 |
# File 'lib/reddit_api/query.rb', line 27 def capture_count records.length end |
#captured_records ⇒ Object
23 24 25 |
# File 'lib/reddit_api/query.rb', line 23 def captured_records records.values end |