class Graphite::Graph
Attributes
allow_children[RW]
id[RW]
leaf[RW]
name[RW]
url[RW]
Public Class Methods
descend_to_leaf(query,path)
click to toggle source
# File lib/graphite/graph.rb, line 20 def self.descend_to_leaf(query,path) result = [] self.find_by_query_and_path(query,path).each do |graph| if graph.leaf return graph else result << self.descend_to_leaf(graph.name + "*",graph.name) end end return result end
find_all_by_query(query)
click to toggle source
# File lib/graphite/graph.rb, line 32 def self.find_all_by_query(query) result = [] self.find_by_query_and_path(query,"").each do |graph| result << self.descend_to_leaf(graph.name + "*",graph.name) end return result.flatten end
find_by_query_and_path(query,path)
click to toggle source
# File lib/graphite/graph.rb, line 7 def self.find_by_query_and_path(query,path) graph_type = "#{self}" == "Graphite::MyGraph" ? "mygraph" : "usergraph" return JSON.parse(self.get("/browser/#{graph_type}/",{:format => "treejson",:query => query,:path =>path}).body).map do |graphic_hash| graphic = MyGraph.new graphic.url = graphic_hash["graphUrl"] graphic.name = graphic_hash["id"] graphic.leaf = graphic_hash["leaf"] == 1 graphic.allow_children = graphic_hash["allowChildren"] == 1 graphic end end