Class: Wolfram::Assumption

Inherits:
Object
  • Object
show all
Extended by:
Util
Includes:
Enumerable, XmlContainer
Defined in:
lib/wolfram/assumption.rb

Defined Under Namespace

Classes: Value

Instance Attribute Summary collapse

Attributes included from XmlContainer

#xml

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

delegate, module_get, to_param, to_query

Methods included from XmlContainer

#respond_to?

Constructor Details

#initialize(xml, options = {}) ⇒ Assumption

Returns a new instance of Assumption.



14
15
16
17
18
19
20
# File 'lib/wolfram/assumption.rb', line 14

def initialize(xml, options = {})
  @query = options[:query]
  @xml = Nokogiri::XML(xml.to_s).search('assumption').first
  @xml or raise MissingNodeError, "<assumption> node missing from xml: #{xml[0..20]}..."
  extend Util.module_get(Assumption, @xml['type'])
  @values = Value.collection(@xml, options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Wolfram::XmlContainer

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



13
14
15
# File 'lib/wolfram/assumption.rb', line 13

def values
  @values
end

Class Method Details

.collection(xml, options = {}) ⇒ Object



9
10
11
# File 'lib/wolfram/assumption.rb', line 9

def self.collection(xml, options = {})
  Nokogiri::XML(xml.to_s).search('assumptions').search('assumption').map {|a_xml| new(a_xml, options)}
end

Instance Method Details

#inspectObject



30
31
32
# File 'lib/wolfram/assumption.rb', line 30

def inspect
  "#<#{to_s}>"
end

#nameObject



22
23
24
# File 'lib/wolfram/assumption.rb', line 22

def name
  xml['type']
end

#to_sObject



26
27
28
# File 'lib/wolfram/assumption.rb', line 26

def to_s
  name + ": " + values.map(&:desc).join(', ')
end