Class: Graphite::Metric

Inherits:
Base
  • Object
show all
Defined in:
lib/graphite/metric.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

authenticate, connection, get, set_connection

Instance Attribute Details

#allow_childrenObject

Returns the value of attribute allow_children.



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

def allow_children
  @allow_children
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#leafObject

Returns the value of attribute leaf.



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

def leaf
  @leaf
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.find_by_query(query) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/graphite/metric.rb', line 7

def self.find_by_query(query)

  return JSON.parse(self.get("/metrics/find",{:format => "treejson",:query => query}).body).map do |metric_hash|
    metric = Metric.new
    metric.name           = metric_hash["text"]
    metric.id             = metric_hash["id"]
    metric.allow_children = metric_hash["allowChildren"] == 1
    metric.leaf           = metric_hash["leaf"] == 1
    metric
  end
end