Class: Apolo::Domains::Cups
- Inherits:
-
Object
- Object
- Apolo::Domains::Cups
- Defined in:
- lib/apolo/domains/cups.rb
Instance Attribute Summary collapse
-
#job ⇒ Object
Returns the value of attribute job.
-
#jobs_count ⇒ Object
Returns the value of attribute jobs_count.
-
#minutes ⇒ Object
Returns the value of attribute minutes.
Instance Method Summary collapse
- #get_data ⇒ Object
-
#initialize(printer_name) ⇒ Cups
constructor
A new instance of Cups.
- #printers ⇒ Object
Constructor Details
#initialize(printer_name) ⇒ Cups
Returns a new instance of Cups.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/apolo/domains/cups.rb', line 7 def initialize(printer_name) if printer_name.nil? printer = CupsPrinter.new(printers.first) @printer_name = printer.name else @printer_name = printer_name end get_data end |
Instance Attribute Details
#job ⇒ Object
Returns the value of attribute job.
6 7 8 |
# File 'lib/apolo/domains/cups.rb', line 6 def job @job end |
#jobs_count ⇒ Object
Returns the value of attribute jobs_count.
6 7 8 |
# File 'lib/apolo/domains/cups.rb', line 6 def jobs_count @jobs_count end |
#minutes ⇒ Object
Returns the value of attribute minutes.
6 7 8 |
# File 'lib/apolo/domains/cups.rb', line 6 def minutes @minutes end |
Instance Method Details
#get_data ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/apolo/domains/cups.rb', line 22 def get_data pointer = FFI::MemoryPointer.new :pointer @jobs_count = CupsFFI::cupsGetJobs(pointer, @printer_name, 0, CupsFFI::CUPS_WHICHJOBS_ACTIVE) @job = CupsFFI::CupsJobS.new(pointer.get_pointer(0)) if @jobs_count > 0 @minutes = (Time.now - Time.at(@job[:creation_time])).to_i / 60 else @minutes = 0 end end |
#printers ⇒ Object
18 19 20 |
# File 'lib/apolo/domains/cups.rb', line 18 def printers CupsPrinter.get_all_printer_names end |