Class: Iora::Models::Result

Inherits:
Element
  • Object
show all
Defined in:
lib/iora/models/result.rb

Overview

The Result class represents a element, the top-level element in queries to the Wolfram Alpha API.

Instance Attribute Summary

Attributes inherited from Element

#element

Instance Method Summary collapse

Methods inherited from Element

#initialize, #to_xml

Methods included from Associations::HasOne

#has_one

Methods included from Associations::Helpers

#parse_element, #tag_for

Methods included from Associations::HasMany

#has_many

Methods included from Associations::HasAttribute

#has_attribute

Constructor Details

This class inherits a constructor from Iora::Models::Element

Instance Method Details

#assumptionsArray<Assumption>


91
# File 'lib/iora/models/result.rb', line 91

has_many :assumptions, Assumption

#datatypesArray<String>


20
# File 'lib/iora/models/result.rb', line 20

has_attribute :datatypes, Array, default: []

#errorError


70
# File 'lib/iora/models/result.rb', line 70

has_one :error, Error

#error?Boolean

Returns true or false depending on whether a serious processing error occurred, such as a missing required parameter. If true there will be no pod content, just an error.

See Also:

  • #errors

27
# File 'lib/iora/models/result.rb', line 27

has_attribute :error?, Boolean

#example_pageExamplePage


76
# File 'lib/iora/models/result.rb', line 76

has_one :example_page, ExamplePage

#future_topicString


111
112
113
# File 'lib/iora/models/result.rb', line 111

def future_topic
  element.at_css('futuretopic').try(:[], 'topic')
end

#idString


31
# File 'lib/iora/models/result.rb', line 31

has_attribute :id

#language_messageLanguageMessage


81
# File 'lib/iora/models/result.rb', line 81

has_one :language_message, LanguageMessage, tag: 'languagemsg'

#parse_timed_out?Boolean


36
# File 'lib/iora/models/result.rb', line 36

has_attribute :parse_timed_out?, Boolean, default: false

#parse_timingFloat


40
# File 'lib/iora/models/result.rb', line 40

has_attribute :parse_timing, Float

#podsArray<Pod>


95
# File 'lib/iora/models/result.rb', line 95

has_many :pods, Pod

#primary_textString


117
118
119
120
121
122
123
# File 'lib/iora/models/result.rb', line 117

def primary_text
  pods.find { |pod| pod.primary? == true }
    .try(:subpods)
    .try(:first)
    .try(:plaintext)
    .try(:strip)
end

#recalculateString


45
# File 'lib/iora/models/result.rb', line 45

has_attribute :recalculate

#reinterpretationReinterpretation


86
# File 'lib/iora/models/result.rb', line 86

has_one :reinterpretation, Reinterpretation, tag: 'reinterpret'

#reinterpreted?Boolean


128
129
130
# File 'lib/iora/models/result.rb', line 128

def reinterpreted?
  reinterpretation.nil? ? false : true
end

#sourcesArray<Source>


101
# File 'lib/iora/models/result.rb', line 101

has_many :sources, Source

#success?Boolean


50
# File 'lib/iora/models/result.rb', line 50

has_attribute :success?, Boolean

#suggestionsArray<String>


106
# File 'lib/iora/models/result.rb', line 106

has_many :suggestions, String, tag: 'didyoumean'

#timed_outInteger


55
# File 'lib/iora/models/result.rb', line 55

has_attribute :timed_out, Array, default: []

#timingFloat


60
# File 'lib/iora/models/result.rb', line 60

has_attribute :timing, Float

#tipsArray<String>


134
135
136
# File 'lib/iora/models/result.rb', line 134

def tips
  element.css('tips > tip').map { |tip| tip[:text] }
end

#versionString


65
# File 'lib/iora/models/result.rb', line 65

has_attribute :version