Sha256: fb01d2df83b85b675b200a69f86eeca3a543b56ae29aca5d270e0cc34e7b9eee

Contents?: true

Size: 632 Bytes

Versions: 1

Compression:

Stored size: 632 Bytes

Contents

module BrDanfe
  module DanfeLib
    class Options < OpenStruct
      DEFAULTOPTIONS = {
        logo: "",
        products_quantity_precision: 2,
        products_unit_price_precision: 2
      }

      def initialize(new_options={})
        options = DEFAULTOPTIONS.merge(config_yaml_load)
        super options.merge(new_options)
      end

      private
      def file
        File.exists?("config/br_danfe.yml") ? File.open("config/br_danfe.yml").read : ""
      end

      def config_yaml_load
        @file_read = YAML.load( file )
        @file_read ? (@file_read["br_danfe"]||{})["options"] : {}
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
br_danfe-0.5.1 lib/br_danfe/danfe_lib/options.rb