Class: FieldDeclarationNode

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

Constant Summary

Constants inherited from ASTNode

ASTNode::DEFAULT_GRAPH_PROPERTIES, ASTNode::METRIC_PROC_FUNCTIONS

Instance Attribute Summary

Attributes inherited from ASTNode

#children, #graph_properties, #parent, #properties, #root_node

Instance Method Summary collapse

Methods inherited from ASTNode

#add_child, #children_of_class, #config=, #default_colors, #initialize, #process_variables, #properties_to_url, #root?, #targets, #to_gdash, #url

Constructor Details

This class inherits a constructor from ASTNode

Instance Method Details

#compileObject



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# 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

#indexObject



246
247
248
# File 'lib/ast_node.rb', line 246

def index
  return parent.children_of_class(FieldDeclarationNode).index(self)
end

#metricObject



197
198
199
200
201
202
203
204
205
206
# 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