Class: Zebra::Epl::CharacterSet

Inherits:
Object
  • Object
show all
Defined in:
lib/zebra/epl/character_set.rb

Defined Under Namespace

Classes: CountryCodeNotApplicableForNumberOfDataBits, InvalidNumberOfDataBits, MissingAttributeError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CharacterSet

Returns a new instance of CharacterSet.



15
16
17
# File 'lib/zebra/epl/character_set.rb', line 15

def initialize(options = {})
  options.each_pair { |attribute, value| self.__send__ "#{attribute}=", value }
end

Instance Attribute Details

#country_codeObject

Returns the value of attribute country_code.



13
14
15
# File 'lib/zebra/epl/character_set.rb', line 13

def country_code
  @country_code
end

#languageObject

Returns the value of attribute language.



13
14
15
# File 'lib/zebra/epl/character_set.rb', line 13

def language
  @language
end

#number_of_data_bitsObject

Returns the value of attribute number_of_data_bits.



13
14
15
# File 'lib/zebra/epl/character_set.rb', line 13

def number_of_data_bits
  @number_of_data_bits
end

Instance Method Details

#to_eplObject



34
35
36
37
38
39
40
41
42
# File 'lib/zebra/epl/character_set.rb', line 34

def to_epl
  raise MissingAttributeError.new("language") if language.nil?
  raise MissingAttributeError.new("number of data bits") if number_of_data_bits.nil?
  raise MissingAttributeError.new("country code") if number_of_data_bits == 8 && country_code.nil?
  raise CountryCodeNotApplicableForNumberOfDataBits if number_of_data_bits == 7 && !country_code.nil?
  Language.validate_language_for_number_of_data_bits language, number_of_data_bits

  ["I#{number_of_data_bits}", language, country_code].compact.join(",")
end