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.
6 7 8 9 10 11 12 |
# File 'lib/reddit_api/query.rb', line 6 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.
4 5 6 |
# File 'lib/reddit_api/query.rb', line 4 def count @count end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
4 5 6 |
# File 'lib/reddit_api/query.rb', line 4 def endpoint @endpoint end |
#offset_id ⇒ Object
Returns the value of attribute offset_id.
4 5 6 |
# File 'lib/reddit_api/query.rb', line 4 def offset_id @offset_id end |
#resource_type ⇒ Object (readonly)
Returns the value of attribute resource_type.
4 5 6 |
# File 'lib/reddit_api/query.rb', line 4 def resource_type @resource_type end |
Instance Method Details
#add_records(new_records) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/reddit_api/query.rb', line 14 def add_records(new_records) if count > 1 add_multiple_records(new_records.compact) else add_single_record(new_records) end end |
#capture_count ⇒ Object
26 27 28 |
# File 'lib/reddit_api/query.rb', line 26 def capture_count records.length end |
#captured_records ⇒ Object
22 23 24 |
# File 'lib/reddit_api/query.rb', line 22 def captured_records records.values end |