Class: Influxdb::Api::ServerVersion

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/influxdb/api/server_version.rb

Defined Under Namespace

Classes: Engine

Constant Summary collapse

REGEXP =

InfluxDB v0.7.3 (git: 023abcdef) (leveldb: 1.7)

/^InfluxDB\sv(\d+)\.(\d+)\.(\d+)\s\(git:\s([0-9abcdef]+)\)\s\((\w+):\s(\d+)\.(\d+)\)$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ ServerVersion

Returns a new instance of ServerVersion.



27
28
29
30
# File 'lib/influxdb/api/server_version.rb', line 27

def initialize(source)
  @source = source
  parse!
end

Instance Attribute Details

#engineObject (readonly)

Returns the value of attribute engine.



25
26
27
# File 'lib/influxdb/api/server_version.rb', line 25

def engine
  @engine
end

#gitObject (readonly)

Returns the value of attribute git.



25
26
27
# File 'lib/influxdb/api/server_version.rb', line 25

def git
  @git
end

#majorObject (readonly)

Returns the value of attribute major.



25
26
27
# File 'lib/influxdb/api/server_version.rb', line 25

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



25
26
27
# File 'lib/influxdb/api/server_version.rb', line 25

def minor
  @minor
end

#patchObject (readonly)

Returns the value of attribute patch.



25
26
27
# File 'lib/influxdb/api/server_version.rb', line 25

def patch
  @patch
end

#sourceObject (readonly)

Returns the value of attribute source.



25
26
27
# File 'lib/influxdb/api/server_version.rb', line 25

def source
  @source
end

Instance Method Details

#<=>(other) ⇒ Object



32
33
34
35
# File 'lib/influxdb/api/server_version.rb', line 32

def <=>(other)
  other_major, other_minor, other_patch = (other.to_s.split('.', 3) + [0] * 3).first(3).map(&:to_i)
  [major <=> other_major, minor <=> other_minor, patch <=> other_patch].detect{|c| c != 0 } || 0
end

#inspectObject



41
42
43
# File 'lib/influxdb/api/server_version.rb', line 41

def inspect
  to_s.inspect
end

#to_sObject



37
38
39
# File 'lib/influxdb/api/server_version.rb', line 37

def to_s
  source
end