Class: MuninPlugin::Attribute

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Attribute

Returns a new instance of Attribute.



7
8
9
10
11
12
13
14
15
# File 'lib/munin_plugin.rb', line 7

def initialize(*args)
  if args.first.is_a?(Attribute)
    @name = [args.shift.name, args.shift].join(".")
  else
    @name = args.first
  end

  @args = args
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



17
18
19
20
21
# File 'lib/munin_plugin.rb', line 17

def method_missing(method, *args, &block)
  @name = [name, method].join(".")
  @args = args
  self
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



5
6
7
# File 'lib/munin_plugin.rb', line 5

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/munin_plugin.rb', line 5

def name
  @name
end

Instance Method Details

#to_sObject



23
24
25
# File 'lib/munin_plugin.rb', line 23

def to_s
  [name, *args].uniq.join(' ')
end