Class: Liberic::Response::Version
- Inherits:
-
Object
- Object
- Liberic::Response::Version
- Defined in:
- lib/liberic/response/version.rb
Constant Summary collapse
- VERSION_NS =
'http://www.elster.de/EricXML/1.0/EricVersion'
Instance Attribute Summary collapse
-
#libs ⇒ Object
readonly
Returns the value of attribute libs.
-
#response_dom ⇒ Object
readonly
Returns the value of attribute response_dom.
-
#response_xml ⇒ Object
readonly
Returns the value of attribute response_xml.
Instance Method Summary collapse
- #for_library(name) ⇒ Object
-
#initialize(response_xml) ⇒ Version
constructor
A new instance of Version.
Constructor Details
#initialize(response_xml) ⇒ Version
Returns a new instance of Version.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/liberic/response/version.rb', line 9 def initialize(response_xml) @response_xml = response_xml @response_dom = Nokogiri::XML(@response_xml) @libs = @response_dom.xpath('//version:Bibliothek', version: VERSION_NS).map do |lib| fields = Hash[ {file: 'Name', product_version: 'Produktversion', file_version: 'Dateiversion'}.map do |key, german_field| [key, lib.xpath("version:#{german_field}", version: VERSION_NS).text] end ] fields[:name] = fields[:file].split('.').first [:product_version, :file_version].each do |version_type| fields[version_type] = fields[version_type].split(',').map(&:strip).join('.') end fields end end |
Instance Attribute Details
#libs ⇒ Object (readonly)
Returns the value of attribute libs.
7 8 9 |
# File 'lib/liberic/response/version.rb', line 7 def libs @libs end |
#response_dom ⇒ Object (readonly)
Returns the value of attribute response_dom.
6 7 8 |
# File 'lib/liberic/response/version.rb', line 6 def response_dom @response_dom end |
#response_xml ⇒ Object (readonly)
Returns the value of attribute response_xml.
6 7 8 |
# File 'lib/liberic/response/version.rb', line 6 def response_xml @response_xml end |
Instance Method Details
#for_library(name) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/liberic/response/version.rb', line 31 def for_library(name) ( @libs.find { |lib| lib[:name] == name } || (raise LibraryNotFound.new("Library #{name} could not be found in this ERiC installation")) )[:product_version] end |