class Squid::Configuration
Provides an object to store global configuration settings.
This class is typically not used directly, but by calling {Squid::Config#configure Squid.configure}, which creates and updates a single instance of {Squid::Configuration}.
@example Set the default height for Squid
graphs:
Squid.configure do |config| config.height = 150 config.steps = 4 end
@see Squid::Config
for more examples.
An alternative way to set global configuration settings is by storing them in the following environment variables:
-
SQUID_HEIGHT
to store the default graph height
In case both methods are used together, {Squid::Config#configure Squid.configure} takes precedence.
@example Set the default graph height:
ENV['SQUID_HEIGHT'] = '150' ENV['SQUID_GRIDLINES'] = '4'
Constants
- ATTRIBUTES
Public Class Methods
array(proc = nil)
click to toggle source
# File lib/squid/configuration.rb, line 47 def self.array(proc = nil) -> (values) { values.split.map{|value| proc ? proc.call(value) : value} } end
boolean()
click to toggle source
# File lib/squid/configuration.rb, line 31 def self.boolean -> (value) { %w(1 t T true TRUE).include? value } end
float()
click to toggle source
# File lib/squid/configuration.rb, line 43 def self.float -> (value) { value.to_f } end
integer()
click to toggle source
# File lib/squid/configuration.rb, line 35 def self.integer -> (value) { value.to_i } end
new()
click to toggle source
Initialize the global configuration settings.
# File lib/squid/configuration.rb, line 70 def initialize ATTRIBUTES.each do |key, options| var = "squid_#{key}".upcase value = ENV.fetch var, options.fetch(:default, '') public_send "#{key}=", options[:as].call(value) end end
symbol()
click to toggle source
# File lib/squid/configuration.rb, line 39 def self.symbol -> (value) { value.to_sym } end