Class: HasBarcode::Configuration
- Inherits:
-
Object
- Object
- HasBarcode::Configuration
- Defined in:
- lib/has_barcode/configuration.rb
Instance Attribute Summary collapse
-
#barcode_class ⇒ Object
readonly
Returns the value of attribute barcode_class.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#outputter_class ⇒ Object
readonly
Returns the value of attribute outputter_class.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Configuration
constructor
A new instance of Configuration.
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_class ⇒ Object (readonly)
Returns the value of attribute barcode_class.
3 4 5 |
# File 'lib/has_barcode/configuration.rb', line 3 def @barcode_class end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/has_barcode/configuration.rb', line 3 def name @name end |
#outputter_class ⇒ Object (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 |