Class: Foomatic::DB
- Inherits:
-
Object
- Object
- Foomatic::DB
- Defined in:
- lib/foomatic.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ DB
constructor
A new instance of DB.
- #printers ⇒ Object
Constructor Details
#initialize(path) ⇒ DB
Returns a new instance of DB.
13 14 15 |
# File 'lib/foomatic.rb', line 13 def initialize(path) @path = Pathname.new(path) end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
11 12 13 |
# File 'lib/foomatic.rb', line 11 def path @path end |
Class Method Details
.open(path = "/usr/share/foomatic/db") ⇒ Object
7 8 9 |
# File 'lib/foomatic.rb', line 7 def self.open(path = "/usr/share/foomatic/db") new(path) end |
Instance Method Details
#printers ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/foomatic.rb', line 17 def printers path.join("source", "printer").each_child.map do |f| xml = Nokogiri::XML.parse(f) Printer.new.tap do |printer| printer.id = xml.root.attribute("id").to_s printer.make = xml.root.xpath("make").text printer.model = xml.root.xpath("model").text printer.url = xml.root.xpath("url").text Printer::MECHANISM_TYPES.each do |type| printer.send("#{type}=", xml.root.xpath("mechanism/#{type}").any?) end end end end |