Class: Wolfram::Pod::State

Inherits:
Object
  • Object
show all
Defined in:
lib/wolfram/pod.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ State

Returns a new instance of State.



82
83
84
85
86
# File 'lib/wolfram/pod.rb', line 82

def initialize(name, options = {})
  @query = options[:query]
  @input = options[:input]
  @name = name
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



74
75
76
# File 'lib/wolfram/pod.rb', line 74

def input
  @input
end

#nameObject (readonly)

Returns the value of attribute name.



74
75
76
# File 'lib/wolfram/pod.rb', line 74

def name
  @name
end

Class Method Details

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



76
77
78
79
80
# File 'lib/wolfram/pod.rb', line 76

def self.collection(xml, options = {})
  Nokogiri::XML(xml.to_s).search('state').map {|s_xml|
    new(s_xml['name'], options.merge(:input => s_xml['input']))
  }
end

Instance Method Details

#inspectObject



96
97
98
# File 'lib/wolfram/pod.rb', line 96

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

#refetchObject



105
106
107
# File 'lib/wolfram/pod.rb', line 105

def refetch
  requery.fetch
end

#requeryObject



100
101
102
103
# File 'lib/wolfram/pod.rb', line 100

def requery
  podstate = @query.params[:podstate] ? [@query.params[:podstate], input] : input
  Query.new(@query.input, @query.options.merge(:podstate => podstate))
end

#to_query(key) ⇒ Object



88
89
90
# File 'lib/wolfram/pod.rb', line 88

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

#to_sObject



92
93
94
# File 'lib/wolfram/pod.rb', line 92

def to_s
  "[#{name}...]"
end