Class: Kameleoon::SdkVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/kameleoon/sdk_version.rb

Overview

SdkManager is a helper method for fetching / obtaining version of SDK from string

Class Method Summary collapse

Class Method Details

.get_float_version(version_string) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/kameleoon/sdk_version.rb', line 21

def self.get_float_version(version_string)
  version_components = get_version_components(version_string)

  return Float::NAN if version_components.nil?

  major = version_components[0]
  minor = version_components[1]
  "#{major}.#{minor}".to_f
end

.get_version_components(version_string) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kameleoon/sdk_version.rb', line 8

def self.get_version_components(version_string)
  versions = [0, 0, 0]

  version_parts = version_string.split('.')
  version_parts.each_with_index do |part, i|
    versions[i] = Integer(part)
  rescue ArgumentError
    Logging::KameleoonLogger.error('Invalid version component, index: %s, value: %s', i, part)
    return nil
  end
  versions
end