Class: WolframAlpha::Response
- Inherits:
-
Object
- Object
- WolframAlpha::Response
- Includes:
- Enumerable
- Defined in:
- library/wolfram-alpha/response.rb
Overview
This is a response object that wraps the response data in a easily managable object.
Instance Attribute Summary collapse
-
#pods ⇒ Object
readonly
Returns the value of attribute pods.
Instance Method Summary collapse
-
#[](id) ⇒ Object
Return the first occurence of a pod with the id of
id
. -
#each ⇒ Object
Calls the given block once for each element in self, passing that element as a parameter.
-
#initialize(document) ⇒ Response
constructor
Construct a new response for a
document
.
Constructor Details
Instance Attribute Details
#pods ⇒ Object (readonly)
Returns the value of attribute pods.
8 9 10 |
# File 'library/wolfram-alpha/response.rb', line 8 def pods @pods end |
Instance Method Details
#[](id) ⇒ Object
Return the first occurence of a pod with the id of id
.
16 17 18 |
# File 'library/wolfram-alpha/response.rb', line 16 def [] id find { |pod| pod.id == id } end |
#each ⇒ Object
Calls the given block once for each element in self, passing that element as a parameter.
An Enumerator is returned if no block is given.
23 24 25 26 27 28 29 |
# File 'library/wolfram-alpha/response.rb', line 23 def each return @pods.to_enum unless block_given? @pods.each do |pod| yield pod end end |