Class: Iora::Models::Subpod

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

Overview

The Subpod class represents a element, an element used by the Wolfram Alpha API to hold some kind of information in the results from a query. Subpod objects include various representations of a single datum.

Depending on the query and what type of results are specified, these representations might include a textual representation, an image, MathML, or Mathematica input/output.

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

#imageImage

Returns the subpod image.

Returns:

  • (Image)

    the subpod image


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

has_one :image, Image, tag: 'img'

#mathematica_inputString

Returns the Mathematica input expression that will generate the same result, if available.

Returns:

  • (String)

    the Mathematica input expression that will generate the same result, if available


38
# File 'lib/iora/models/subpod.rb', line 38

has_one :mathematica_input, String, tag: 'minput'

#mathematica_outputString

Returns the text format that you see in the "Mathematica plaintext output" popup that appears when you click some results on the Wolfram|Alpha site.

Returns:

  • (String)

    the text format that you see in the "Mathematica plaintext output" popup that appears when you click some results on the Wolfram|Alpha site.


44
# File 'lib/iora/models/subpod.rb', line 44

has_one :mathematica_output, String, tag: 'moutput'

#mathmlMathML

Returns the subpod MathML representation. Unlike you might imagine, many queries that are not math-related include MathML results. For example, the query "g major scale" returns a MathML representation of the scale.

Returns:

  • (MathML)

    the subpod MathML representation. Unlike you might imagine, many queries that are not math-related include MathML results. For example, the query "g major scale" returns a MathML representation of the scale.


51
52
53
# File 'lib/iora/models/subpod.rb', line 51

def mathml
  MathML.new(element.at_css('mathml|math', 'mathml' => 'http://www.w3.org/1998/Math/MathML'))
end

#plaintextString Also known as: text

Returns the textual representation of the subpod.

Returns:

  • (String)

    the textual representation of the subpod


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

has_one :plaintext, String

#primary?String

Returns true or false depending on whether the subpod is the primary subpod for the query.

Returns:

  • (String)

    true or false depending on whether the subpod is the primary subpod for the query


23
# File 'lib/iora/models/subpod.rb', line 23

has_attribute :primary?, Boolean, default: false

#titleString

Returns the subpod's title.

Returns:

  • (String)

    the subpod's title


18
# File 'lib/iora/models/subpod.rb', line 18

has_attribute :title