Class: HasBarcode::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/has_barcode/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Configuration

Returns a new instance of Configuration.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/has_barcode/configuration.rb', line 4

def initialize(*args)
  opts = ActiveSupport::HashWithIndifferentAccess.new(args.last.kind_of?(Hash) ? (args.last || {}) : {})

  @name = args.first

  if opts[:type].kind_of?(String) || opts[:type].kind_of?(Symbol)
    require "barby/barcode/#{opts[:type]}"
    @barcode_class = Barby.const_get(ActiveSupport::Inflector.classify("#{opts[:type].to_s}"))
  else
    @barcode_class = opts[:type]
  end

  require "barby/outputter/#{opts[:outputter]}_outputter"
  @outputter = Barby.const_get(ActiveSupport::Inflector.classify("#{opts[:outputter]}_outputter"))
end

Instance Attribute Details

#barcode_classObject (readonly)

Returns the value of attribute barcode_class.



3
4
5
# File 'lib/has_barcode/configuration.rb', line 3

def barcode_class
  @barcode_class
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/has_barcode/configuration.rb', line 3

def name
  @name
end

#outputter_classObject (readonly)

Returns the value of attribute outputter_class.



3
4
5
# File 'lib/has_barcode/configuration.rb', line 3

def outputter_class
  @outputter_class
end