Class: OnlyofficeDocumentserverTestingFramework::DocumentServerVersion

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/onlyoffice_documentserver_testing_framework/document_server_version.rb

Overview

Class for working with DocumentServer version

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(major = 0, minor = 0, patch = 0, build = 0) ⇒ DocumentServerVersion

rubocop:disable Metrics/ParameterLists



18
19
20
21
22
23
# File 'lib/onlyoffice_documentserver_testing_framework/document_server_version.rb', line 18

def initialize(major = 0, minor = 0, patch = 0, build = 0)
  @major = major
  @minor = minor
  @patch = patch
  @build = build
end

Instance Attribute Details

#buildInteger (readonly)

Returns Build version.

Returns:

  • (Integer)

    Build version



15
16
17
# File 'lib/onlyoffice_documentserver_testing_framework/document_server_version.rb', line 15

def build
  @build
end

#majorInteger (readonly)

Returns Major version.

Returns:

  • (Integer)

    Major version



9
10
11
# File 'lib/onlyoffice_documentserver_testing_framework/document_server_version.rb', line 9

def major
  @major
end

#minorInteger (readonly)

Returns Minor version.

Returns:

  • (Integer)

    Minor version



11
12
13
# File 'lib/onlyoffice_documentserver_testing_framework/document_server_version.rb', line 11

def minor
  @minor
end

#patchInteger (readonly)

Returns Patch version.

Returns:

  • (Integer)

    Patch version



13
14
15
# File 'lib/onlyoffice_documentserver_testing_framework/document_server_version.rb', line 13

def patch
  @patch
end

Instance Method Details

#<=>(other) ⇒ Integer

Compare two DocumentServerVersion

Parameters:

Returns:

  • (Integer)

    result of compare



53
54
55
56
# File 'lib/onlyoffice_documentserver_testing_framework/document_server_version.rb', line 53

def <=>(other)
  Gem::Version.new(to_dotted_string) <=>
    Gem::Version.new(other.to_dotted_string)
end

#parse(string) ⇒ DocumentServerVersion

Returns result of parsing.

Parameters:

  • string (String)

    string value of build to parse

Returns:



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/onlyoffice_documentserver_testing_framework/document_server_version.rb', line 28

def parse(string)
  return self if string == 'Unknown'

  split_by_dot = string.split('.')
  split_by_space = split_by_dot[2].split
  @major = split_by_dot[0].to_i
  @minor = split_by_dot[1].to_i
  @patch = split_by_space[0].to_i
  @build = split_by_space[1].scan(/\d/).join.to_i
  self
end

#to_dotted_stringString

Returns sting with all digits separted by dots.

Returns:

  • (String)

    sting with all digits separted by dots



46
47
48
# File 'lib/onlyoffice_documentserver_testing_framework/document_server_version.rb', line 46

def to_dotted_string
  "#{@major}.#{@minor}.#{@patch}.#{@build}"
end

#to_sString

Returns string value.

Returns:

  • (String)

    string value



41
42
43
# File 'lib/onlyoffice_documentserver_testing_framework/document_server_version.rb', line 41

def to_s
  "#{@major}.#{@minor}.#{@patch} (build:#{@build})"
end