Class: Graphite::RawParser
- Inherits:
-
Object
- Object
- Graphite::RawParser
- Defined in:
- lib/graphite/raw_parser.rb
Class Method Summary collapse
-
.parse(lines) ⇒ Object
returns an array of arrays of pairs with 2 elements timestamp and value (may be nil).
Class Method Details
.parse(lines) ⇒ Object
returns an array of arrays of pairs with 2 elements timestamp and value (may be nil)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/graphite/raw_parser.rb', line 4 def self.parse(lines) lines.strip.split("\n").map do |line| metric, startTime, endTime, interval, dataStr = /(.*),(\d+),(\d+),(\d+)\|(.*)/.match(line)[1..-1] data = dataStr.split(",") 0.upto(data.length - 1).map do |i| value = data[i] { :metric => metric, :timestamp => startTime.to_i + (interval.to_i * i), :value => !value.nil? ? value.to_f : value } end end end |