Module: RRD

Extended by:
RRD
Included in:
RRD
Defined in:
lib/rrd.rb,
lib/rrd/base.rb,
lib/rrd/graph.rb,
lib/rrd/xport.rb,
lib/rrd/builder.rb,
lib/rrd/version.rb,
lib/rrd/wrapper.rb

Defined Under Namespace

Modules: Version Classes: Base, Builder, Graph, Wrapper, Xport

Constant Summary collapse

BANG_METHODS =
[:graph!, :xport!]

Instance Method Summary collapse

Instance Method Details

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



55
56
57
58
59
# File 'lib/rrd.rb', line 55

def bang(method, *args, &block)
  result = send(method, *args, &block)
  raise error unless result
  result
end

#errorObject



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

def error
  Wrapper.error
end

#graph(image_file, options = {}, &block) ⇒ Object



16
17
18
19
20
# File 'lib/rrd.rb', line 16

def graph(image_file, options = {}, &block)
  graph = Graph.new(image_file, options)
  graph.instance_eval(&block)
  graph.save
end

#methodsObject



51
52
53
# File 'lib/rrd.rb', line 51

def methods
  super + BANG_METHODS
end

#to_line_parameters(hash, known_flags = []) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rrd.rb', line 32

def to_line_parameters(hash, known_flags = [])
  used_flags = []
  known_flags.each do |flag|
    used_flags << "--#{flag}".gsub(/_/, "-") if hash.delete(flag)
  end

  line_params = []

  hash.each_pair do |key,value|
    if value.kind_of? Array
      value.each {|v| line_params += ["--#{key}".gsub(/_/, "-"), v.to_s]}
    else
      line_params += ["--#{key}".gsub(/_/, "-"), value.to_s]
    end
  end

  used_flags + line_params
end

#xport(options = {}, &block) ⇒ Object



22
23
24
25
26
# File 'lib/rrd.rb', line 22

def xport(options = {}, &block)
  xport = Xport.new(options)
  xport.instance_eval(&block)
  xport.save
end