Sha256: 5fedd3f8b869870bb12b933adb3e8817d6ea687a647fc014baa10f64dbf22a3c
Contents?: true
Size: 983 Bytes
Versions: 5
Compression:
Stored size: 983 Bytes
Contents
module RubyUnits class << self attr_writer :configuration end def self.configuration @configuration ||= Configuration.new end def self.reset @configuration = Configuration.new end # allow for optional configuration of RubyUnits # # Usage: # # RubyUnits.configure do |config| # config.separator = false # end def self.configure yield configuration end # holds actual configuration values for RubyUnits class Configuration # Used to separate the scalar from the unit when generating output. A value # of `true` will insert a single space, and `false` will prevent adding a # space to the string representation of a unit. attr_reader :separator def initialize self.separator = true end def separator=(value) raise ArgumentError, "configuration 'separator' may only be true or false" unless [true, false].include?(value) @separator = value ? ' ' : nil end end end
Version data entries
5 entries across 5 versions & 1 rubygems