class FieldDeclarationNode

Public Instance Methods

compile() click to toggle source
# File lib/ast_node.rb, line 208
def compile
  aux = children.first.apply_function(metric.gsub("-","_"))
  children[1..-1].each do |i|
    aux = i.apply_function(aux)
  end if children[1..-1]
  if self.root_node.properties[:logarithmic]
    # NOT IMPLEMENTED the logarithmic means that a logarithmic scale is to be used not that a log function has to be implemented aux = "log(#{aux},10)"
  end

  if self.properties[:stacked]
    aux = "stacked(#{aux})"
  end
  
  if self.properties[:yMax] && !self.properties[:proccessed]
    self.properties[:proccessed] = true
    return self.compile
  end
  
  if self.properties[:is_negative]
    aux = "scale(#{aux},-1)"
    self.properties[:alias] = "" # legend is discarded in this case (munin does so)
  end

  if self.properties[:alias]
    aux =  "alias(#{aux},'#{self.properties[:alias]}')"
  end

  METRIC_PROC_FUNCTIONS.each do |proc|
    aux = proc.call(self,aux)
  end

  if self.properties[:hide]
    return nil
  else
    return aux
  end
end
index() click to toggle source
# File lib/ast_node.rb, line 246
def index
  return parent.children_of_class(FieldDeclarationNode).index(self)
end
metric() click to toggle source
# File lib/ast_node.rb, line 197
def metric
  [
   root_node.properties['graphite_user'],
   root_node.properties['graphite_prefix'],
   root_node.properties['hostname'].split('.').first,
   root_node.properties['category'],
   root_node.properties['metric'],
   children.first.metric
  ].reject{|i| i == "" }.compact.join(".")
end