Sha256: f07d3a57054904892bfd6ef50badc920de8cc73560229596b2a5cdd29ce34773

Contents?: true

Size: 758 Bytes

Versions: 3

Compression:

Stored size: 758 Bytes

Contents

module L2meter
  class Configuration
    attr_writer :output
    attr_accessor :source, :prefix, :float_precision
    attr_reader :context, :key_formatter, :output

    DEFAULT_KEY_FORMATTER = ->(key) do
      key.to_s.strip.downcase.gsub(/[^-a-z\d.#]+/, ?-)
    end

    private_constant :DEFAULT_KEY_FORMATTER

    def initialize
      @sort = false
      @key_formatter = DEFAULT_KEY_FORMATTER
      @output = $stdout
      @float_precision = 4
    end

    def format_keys(&block)
      @key_formatter = block
    end

    def sort?
      @sort
    end

    def sort=(value)
      @sort = !!value
    end

    def context
      if block_given?
        @context = Proc.new
      else
        @context
      end
    end

    attr_writer :context
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
l2meter-0.9.1 lib/l2meter/configuration.rb
l2meter-0.9.0 lib/l2meter/configuration.rb
l2meter-0.8.0 lib/l2meter/configuration.rb