Class: OnlyofficeDocumentserverTestingFramework::DocumentServerVersion
- Inherits:
-
Object
- Object
- OnlyofficeDocumentserverTestingFramework::DocumentServerVersion
- Includes:
- Comparable
- Defined in:
- lib/onlyoffice_documentserver_testing_framework/document_server_version.rb
Overview
Class for working with DocumentServer version
Instance Attribute Summary collapse
-
#build ⇒ Integer
readonly
Build version.
-
#major ⇒ Integer
readonly
Major version.
-
#minor ⇒ Integer
readonly
Minor version.
-
#patch ⇒ Integer
readonly
Patch version.
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
Compare two DocumentServerVersion.
-
#initialize(major = 0, minor = 0, patch = 0, build = 0) ⇒ DocumentServerVersion
constructor
rubocop:disable Metrics/ParameterLists.
-
#parse(string) ⇒ DocumentServerVersion
Result of parsing.
-
#to_dotted_string ⇒ String
Sting with all digits separted by dots.
-
#to_s ⇒ String
String value.
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
#build ⇒ Integer (readonly)
Returns Build version.
15 16 17 |
# File 'lib/onlyoffice_documentserver_testing_framework/document_server_version.rb', line 15 def build @build end |
#major ⇒ Integer (readonly)
Returns Major version.
9 10 11 |
# File 'lib/onlyoffice_documentserver_testing_framework/document_server_version.rb', line 9 def major @major end |
#minor ⇒ Integer (readonly)
Returns Minor version.
11 12 13 |
# File 'lib/onlyoffice_documentserver_testing_framework/document_server_version.rb', line 11 def minor @minor end |
#patch ⇒ Integer (readonly)
Returns 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
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.
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_string ⇒ String
Returns 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_s ⇒ String
Returns 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 |