Class: StarEthernet::Status
- Inherits:
-
Object
- Object
- StarEthernet::Status
- Defined in:
- lib/star_ethernet/status.rb
Instance Attribute Summary collapse
-
#status_items ⇒ Object
readonly
Returns the value of attribute status_items.
Instance Method Summary collapse
- #current_status ⇒ Object
- #etb_incremented? ⇒ Boolean
- #full_messages ⇒ Object
-
#initialize(printer) ⇒ Status
constructor
A new instance of Status.
- #previous_status ⇒ Object
- #set_status(status_data, purpose = '') ⇒ Object
Constructor Details
#initialize(printer) ⇒ Status
Returns a new instance of Status.
7 8 9 10 |
# File 'lib/star_ethernet/status.rb', line 7 def initialize(printer) @printer = printer @status_items = [] end |
Instance Attribute Details
#status_items ⇒ Object (readonly)
Returns the value of attribute status_items.
5 6 7 |
# File 'lib/star_ethernet/status.rb', line 5 def status_items @status_items end |
Instance Method Details
#current_status ⇒ Object
12 13 14 |
# File 'lib/star_ethernet/status.rb', line 12 def current_status @status_items.last end |
#etb_incremented? ⇒ Boolean
20 21 22 23 24 25 26 27 |
# File 'lib/star_ethernet/status.rb', line 20 def etb_incremented? return false if previous_status.nil? if previous_status.etb == 31 # ETB overflow current_status.etb == 0 else current_status.etb == previous_status.etb + 1 end end |
#full_messages ⇒ Object
35 36 37 38 39 40 |
# File 'lib/star_ethernet/status.rb', line 35 def <<~"EOS" #{@printer.host} printer's statuses are #{@status_items.map{ |status_item| status_item. }.join("\n")} EOS end |
#previous_status ⇒ Object
16 17 18 |
# File 'lib/star_ethernet/status.rb', line 16 def previous_status @status_items[-2] end |
#set_status(status_data, purpose = '') ⇒ Object
29 30 31 32 33 |
# File 'lib/star_ethernet/status.rb', line 29 def set_status(status_data, purpose = '') current_status = StatusItem.decode_status(status_data) current_status.purpose = purpose @status_items.push(current_status) end |