Class: InfluxRemix::Remix

Inherits:
Object
  • Object
show all
Defined in:
lib/influx_remix/remix.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Remix

Returns a new instance of Remix.



3
4
5
# File 'lib/influx_remix/remix.rb', line 3

def initialize(data)
    @data = data
end

Instance Method Details

#fieldsObject



25
26
27
28
29
# File 'lib/influx_remix/remix.rb', line 25

def fields
    elements = @data.split(' ') 
    chunk = elements[1].split(',')
    transform_data(chunk) 
end

#line_protocolObject



42
43
44
# File 'lib/influx_remix/remix.rb', line 42

def line_protocol
    @data
end

#measurementObject



7
8
9
10
11
12
13
14
# File 'lib/influx_remix/remix.rb', line 7

def measurement
    elements = @data.split(',')
    if has_measurement?
        return elements.first
    else 
        return nil
    end
end

#tagsObject



16
17
18
19
20
21
22
23
# File 'lib/influx_remix/remix.rb', line 16

def tags
    elements = @data.split(' ')
    chunk = elements.first.split(',')
    if has_measurement?
        chunk.shift
    end
    transform_data(chunk) 
end

#timeObject



31
32
33
# File 'lib/influx_remix/remix.rb', line 31

def time
    @data.split(' ').last
end

#update_time(time) ⇒ Object



35
36
37
38
39
40
# File 'lib/influx_remix/remix.rb', line 35

def update_time(time)
    info = @data.split(' ')
    info.pop
    info.push(time.to_s)
    @data = info.join(' ')
end