Class: IERail::IERailGet
- Inherits:
-
Nokogiri::XML::SAX::Document
- Object
- Nokogiri::XML::SAX::Document
- IERail::IERailGet
- Defined in:
- lib/ierail.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #characters(string) ⇒ Object
- #end_element(name) ⇒ Object
-
#initialize(url, array_name, object_name) ⇒ IERailGet
constructor
A new instance of IERailGet.
- #response ⇒ Object
- #start_document ⇒ Object
- #start_element(name, attrs = []) ⇒ Object
Constructor Details
#initialize(url, array_name, object_name) ⇒ IERailGet
Returns a new instance of IERailGet.
20 21 22 23 24 |
# File 'lib/ierail.rb', line 20 def initialize(url, array_name, object_name) @ws_url = URI.encode(url) @ws_array_name = array_name.downcase @ws_object_name = object_name.downcase end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
18 19 20 |
# File 'lib/ierail.rb', line 18 def result @result end |
Instance Method Details
#characters(string) ⇒ Object
38 39 40 41 |
# File 'lib/ierail.rb', line 38 def characters string string.strip! @result.last[@current] << string unless string.empty? end |
#end_element(name) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/ierail.rb', line 55 def end_element name if @current && @result.last[@current].empty? @result.last.delete(@current) end @current = nil end |
#response ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/ierail.rb', line 26 def response unless @result parser = Nokogiri::XML::SAX::Parser.new(self) parser.parse(RestClient.get(URL + "/" + @ws_url)) end @result end |
#start_document ⇒ Object
34 35 36 |
# File 'lib/ierail.rb', line 34 def start_document @result = [] end |
#start_element(name, attrs = []) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ierail.rb', line 43 def start_element name, attrs = [] case name.downcase when @ws_object_name @result << Hash.new when @ws_array_name ; else @current = name @result.last[@current] = "" end end |