Skip to content

Commit

Permalink
Google::Search::Response now enumerable
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jul 23, 2009
1 parent f45f2c7 commit 0ed240d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/google-search/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ module Google
class Search
class Response

#--
# Mixins
#++

include Enumerable

##
# Response status code.

Expand Down Expand Up @@ -66,6 +72,14 @@ def initialize hash
end
end

##
# Iterate each item with _block_.

def each_item &block
items.each { |item| yield item }
end
alias :each :each_item

##
# Check if the response is valid.

Expand Down
2 changes: 1 addition & 1 deletion lib/google-search/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def initialize type, options = {}
def each_item &block
response = self.next.response
if response.valid?
response.items.each { |item| yield item }
response.each { |item| yield item }
each_item &block
end
end
Expand Down

0 comments on commit 0ed240d

Please sign in to comment.