Class: Rdpl::Label
Constant Summary collapse
- START =
'L'- FINISH =
'E'- DEFAULT_DOT_SIZE =
11- DEFAULT_HEAT =
14
Instance Attribute Summary collapse
-
#job ⇒ Object
writeonly
Sets the attribute job.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #<<(arg) ⇒ Object
- #[](arg) ⇒ Object
- #dot_size ⇒ Object
- #dump ⇒ Object
- #end! ⇒ Object
- #heat ⇒ Object
-
#initialize(options = {}) ⇒ Label
constructor
A new instance of Label.
- #mm? ⇒ Boolean
-
#start_of_print ⇒ Object
Returns the start of print position for the label.
Methods included from Commandable
Constructor Details
#initialize(options = {}) ⇒ Label
Returns a new instance of Label.
13 14 15 16 |
# File 'lib/label.rb', line 13 def initialize( = {}) @contents = '' start end |
Instance Attribute Details
#job=(value) ⇒ Object (writeonly)
Sets the attribute job
4 5 6 |
# File 'lib/label.rb', line 4 def job=(value) @job = value end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
3 4 5 |
# File 'lib/label.rb', line 3 def quantity @quantity end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
3 4 5 |
# File 'lib/label.rb', line 3 def state @state end |
Instance Method Details
#<<(arg) ⇒ Object
32 33 34 35 |
# File 'lib/label.rb', line 32 def <<(arg) raise EndedElementError unless state == :open @contents << arg.to_s << NEW_LINE end |
#[](arg) ⇒ Object
28 29 30 |
# File 'lib/label.rb', line 28 def [](arg) @contents[arg] end |
#dot_size ⇒ Object
37 38 39 |
# File 'lib/label.rb', line 37 def dot_size @dot_size || DEFAULT_DOT_SIZE end |
#dump ⇒ Object
18 19 20 |
# File 'lib/label.rb', line 18 def dump @contents.dup end |
#end! ⇒ Object
22 23 24 25 26 |
# File 'lib/label.rb', line 22 def end! self << formatted_quantity unless quantity.nil? self << FINISH self.state = :finished end |
#heat ⇒ Object
41 42 43 |
# File 'lib/label.rb', line 41 def heat @heat || DEFAULT_HEAT end |
#mm? ⇒ Boolean
45 46 47 |
# File 'lib/label.rb', line 45 def mm? @job ? @job.mm? : false end |
#start_of_print ⇒ Object
Returns the start of print position for the label. If the option wasn’t specified in the label’s constructor, nil will be returned and the printer will assume the default start of print.
It works this way since the default value for this parameter depends on the printer’s model.
54 55 56 57 |
# File 'lib/label.rb', line 54 def start_of_print return nil if @start_of_print.nil? @start_of_print.to_f / (mm? ? 10 : 100) end |