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.
19 20 21 22 23 |
# File 'lib/ierail.rb', line 19 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.
17 18 19 |
# File 'lib/ierail.rb', line 17 def result @result end |
Instance Method Details
#characters(string) ⇒ Object
37 38 39 40 |
# File 'lib/ierail.rb', line 37 def characters string string.strip! @result.last[@current] << string unless string.empty? end |
#end_element(name) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/ierail.rb', line 54 def end_element name if @current && @result.last[@current].empty? @result.last.delete(@current) end @current = nil end |
#response ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ierail.rb', line 25 def response unless @result parser = Nokogiri::XML::SAX::Parser.new(self) parser.parse(RestClient.get(URL + "/" + @ws_url)) end @result end |
#start_document ⇒ Object
33 34 35 |
# File 'lib/ierail.rb', line 33 def start_document @result = [] end |
#start_element(name, attrs = []) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ierail.rb', line 42 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 |