Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Yql::Response class and modify Yql::Client class to
return response object
- Loading branch information
nas
committed
Jun 20, 2010
1 parent
f370ed0
commit 7925c6e
Showing
4 changed files
with
46 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module Yql | ||
|
||
class Response | ||
|
||
def initialize(response, format) | ||
@response = response | ||
@format = format | ||
end | ||
|
||
def show | ||
raise Yql::ResponseFailure, body.inspect unless success? | ||
output | ||
end | ||
|
||
def body | ||
@response.body | ||
end | ||
|
||
def code | ||
@response.code | ||
end | ||
|
||
def success? | ||
code == '200' | ||
end | ||
|
||
private | ||
|
||
def output | ||
return body unless @format == 'xml' | ||
REXML::Document.new(body) | ||
end | ||
|
||
end | ||
|
||
end |