Module: Wolfram
- Extended by:
- Wolfram
- Included in:
- Wolfram
- Defined in:
- lib/wolfram.rb,
lib/wolfram/pod.rb,
lib/wolfram/util.rb,
lib/wolfram/query.rb,
lib/wolfram/result.rb,
lib/wolfram/version.rb,
lib/wolfram/assumption.rb,
lib/wolfram/xml_container.rb,
lib/wolfram/hash_presenter.rb
Defined Under Namespace
Modules: Util, XmlContainer Classes: Assumption, HashPresenter, MissingNodeError, Pod, Query, Result
Constant Summary collapse
- DefaultQueryURI =
"http://api.wolframalpha.com/v2/query"
- VERSION =
'0.2.0'
Instance Attribute Summary collapse
-
#appid ⇒ Object
Returns the value of attribute appid.
-
#query_uri ⇒ Object
Returns the value of attribute query_uri.
Instance Method Summary collapse
- #fetch(input, options = {}) ⇒ Object
- #query(input, options = {}) ⇒ Object
- #run(argv = ARGV) ⇒ Object
Instance Attribute Details
#appid ⇒ Object
Returns the value of attribute appid.
16 17 18 |
# File 'lib/wolfram.rb', line 16 def appid @appid end |
#query_uri ⇒ Object
Returns the value of attribute query_uri.
16 17 18 |
# File 'lib/wolfram.rb', line 16 def query_uri @query_uri end |
Instance Method Details
#fetch(input, options = {}) ⇒ Object
26 27 28 |
# File 'lib/wolfram.rb', line 26 def fetch(input, = {}) query(input, ).fetch end |
#query(input, options = {}) ⇒ Object
22 23 24 |
# File 'lib/wolfram.rb', line 22 def query(input, = {}) Query.new(input, ) end |
#run(argv = ARGV) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/wolfram.rb', line 30 def run(argv=ARGV) return puts("Usage: wolfram QUERY") if argv.empty? puts fetch(argv.join(' ')).inspect rescue MissingNodeError warn "Wolfram Error: Invalid response - #{$!.}" rescue RuntimeError warn "Wolfram Error: #{$!.}" end |