Class: Munin::Field
- Inherits:
-
Object
- Object
- Munin::Field
- Defined in:
- lib/munin.rb
Constant Summary collapse
- DATA_SOURCE_ATTRIBUTES =
%w{ label cdef draw graph extinfo max min negative type warning critical colour skipdraw sum stack line }
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #config ⇒ Object
- #default_label(name) ⇒ Object
-
#initialize(name, options = {}) ⇒ Field
constructor
A new instance of Field.
- #option(key) ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Field
Returns a new instance of Field.
164 165 166 167 168 |
# File 'lib/munin.rb', line 164 def initialize(name, = {}) @name, @options = name.to_s, @options[:label] ||= default_label(name) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
162 163 164 |
# File 'lib/munin.rb', line 162 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
162 163 164 |
# File 'lib/munin.rb', line 162 def @options end |
Instance Method Details
#==(other) ⇒ Object
197 198 199 |
# File 'lib/munin.rb', line 197 def ==(other) other and name == other.name and == other. end |
#config ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/munin.rb', line 180 def config DATA_SOURCE_ATTRIBUTES.inject({}) do |config, attribute| attribute = attribute.to_sym attribute_value = @options[attribute] unless attribute_value.nil? case attribute when :type attribute_value = attribute_value.to_s.upcase end config["#{name}.#{attribute}"] = attribute_value end config end end |
#default_label(name) ⇒ Object
170 171 172 |
# File 'lib/munin.rb', line 170 def default_label(name) name.to_s.gsub('_',' ') end |
#option(key) ⇒ Object
174 175 176 |
# File 'lib/munin.rb', line 174 def option(key) @options[key] end |