Class: LibyearBundler::Calculators::VersionNumberDelta

Inherits:
Object
  • Object
show all
Defined in:
lib/libyear_bundler/calculators/version_number_delta.rb

Overview

The version number delta is the absolute difference between the highest- order version number of the installed and newest releases

Class Method Summary collapse

Class Method Details

.calculate(installed_version, newest_version) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/libyear_bundler/calculators/version_number_delta.rb', line 7

def calculate(installed_version, newest_version)
  installed_version_tuple = version_tuple(installed_version.to_s.split('.'))
  newest_version_tuple = version_tuple(newest_version.to_s.split('.'))
  major_version_delta = version_delta(
    newest_version_tuple.major, installed_version_tuple.major
  )
  minor_version_delta = version_delta(
    newest_version_tuple.minor, installed_version_tuple.minor
  )
  patch_version_delta = version_delta(
    newest_version_tuple.patch, installed_version_tuple.patch
  )
  highest_order([major_version_delta, minor_version_delta, patch_version_delta])
end