Class: Wolfram::Assumption::Value

Inherits:
Object
  • Object
show all
Includes:
XmlContainer
Defined in:
lib/wolfram/assumption.rb

Instance Attribute Summary

Attributes included from XmlContainer

#xml

Class Method Summary collapse

Instance Method Summary collapse

Methods included from XmlContainer

#respond_to?

Constructor Details

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

Returns a new instance of Value.



41
42
43
44
45
# File 'lib/wolfram/assumption.rb', line 41

def initialize(xml, options = {})
  @query = options[:query]
  @xml = Nokogiri::XML(xml.to_s).search('value').first
  @xml or raise MissingNodeError, "<value> node missing from xml: #{xml[0..20]}..."
end

Dynamic Method Handling

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

Class Method Details

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



37
38
39
# File 'lib/wolfram/assumption.rb', line 37

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

Instance Method Details

#inspectObject



47
48
49
# File 'lib/wolfram/assumption.rb', line 47

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

#refetchObject



59
60
61
# File 'lib/wolfram/assumption.rb', line 59

def refetch
  requery.fetch
end

#requeryObject



55
56
57
# File 'lib/wolfram/assumption.rb', line 55

def requery
  Query.new(@query.input, @query.options.merge(:assumption => self))
end

#to_query(key) ⇒ Object



63
64
65
# File 'lib/wolfram/assumption.rb', line 63

def to_query(key)
  Util.to_query(input, key)
end

#to_sObject



51
52
53
# File 'lib/wolfram/assumption.rb', line 51

def to_s
  desc
end