pebble / airbrite-ruby

Ruby bindings for the Airbrite API.
https://github.com/pebble/airbrite-ruby
MIT License
5 stars 6 forks source link

`result.paging.count` gives incorrect value. #2

Open crazy2be opened 10 years ago

crazy2be commented 10 years ago

Using the following code to get all orders:

skip = 0
while true
  result = Airbrite::Order.list(limit: 1000, skip: skip)
  # Process the data...
  skip = result.paging.offset + result.paging.count
  break unless result.paging.has_more
end

Always returns 5 for result.paging.count. Using result.paging["count"] works as expected.

I suppose this is likely because result.paging is a hash, so it has it's own count property. Might be worth noting in the docs (or just leaving this issue here for people to find).

bhbryant commented 10 years ago

This is unfortunate, but expected behavior.

Airbrite::Order is actually hash, so .count yields the number of items in the hash element.

Confusing, but is what it is.

Ben

On Wed, Nov 13, 2013 at 5:54 PM, crazy2be notifications@github.com wrote:

Using the following code to get all orders:

skip = 0 while true result = Airbrite::Order.list(limit: 1000, skip: skip)

Process the data...

skip = result.paging.offset + result.paging.count break unless result.paging.has_more end

Always returns 5 for result.paging.count. Using result.paging["count"]works as expected.

I suppose this is likely because result.paging is a hash, so it has it's own count property. Might be worth noting in the docs (or just leaving this issue here for people to find).

— Reply to this email directly or view it on GitHubhttps://github.com/pebble/airbrite-ruby/issues/2 .