Sha256: 0045013e4a15c336a5edbd0758dce84457324acda7a91640e45a1163159c7d76

Contents?: true

Size: 637 Bytes

Versions: 6

Compression:

Stored size: 637 Bytes

Contents

module BrDanfe
  module DanfeLib
    class Options < OpenStruct
      DEFAULTOPTIONS = {
        logo_path: "",
        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

6 entries across 6 versions & 1 rubygems

Version Path
br_danfe-0.5.0 lib/br_danfe/danfe_lib/options.rb
br_danfe-0.4.3 lib/br_danfe/danfe_lib/options.rb
br_danfe-0.4.2 lib/br_danfe/danfe_lib/options.rb
br_danfe-0.4.1 lib/br_danfe/danfe_lib/options.rb
br_danfe-0.4.0 lib/br_danfe/danfe_lib/options.rb
br_danfe-0.3.0 lib/br_danfe/danfe_lib/options.rb