Class: Humr::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/humr/config.rb

Constant Summary collapse

DEFAULT =
{
  :handlers => [
    :url, :si, :time, :ua
  ],
  :handler => {
    :url  => { :color => :green   },
    :si   => { :color => :cyan    },
    :time => { :color => :yellow  },
    :ua   => { :color => :magenta },
  }
}
COLORS =
[
  :red,
  :green,
  :yellow,
  :blue,
  :magenta,
  :cyan
]

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



24
25
26
# File 'lib/humr/config.rb', line 24

def initialize
  @config = DEFAULT.dup
end

Instance Method Details

#color(handler) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/humr/config.rb', line 32

def color(handler)
  name = if handler.kind_of?(Symbol)
    handler
  else
    handler.name
  end

  @config[:handler][name][:color]
end

#handlersObject



28
29
30
# File 'lib/humr/config.rb', line 28

def handlers
  @config[:handlers].map(&:to_sym)
end