Class: Fastlane::Helper::GoodifyInfoPlistVersionHelper

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/fastlane/plugin/goodify_info_plist/helper/version_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version_string) ⇒ GoodifyInfoPlistVersionHelper

Returns a new instance of GoodifyInfoPlistVersionHelper.



14
15
16
17
18
19
20
21
# File 'lib/fastlane/plugin/goodify_info_plist/helper/version_helper.rb', line 14

def initialize(version_string)
  match = /^(?<major_version>\d+)\.(?<minor_version>\d+)\.(?<patch_version>\d+)\.(?<build_number>\d+)$/.match(version_string) || {}

  @major_version = (match[:major_version] || '0').to_i
  @minor_version = (match[:minor_version] || '0').to_i
  @patch_version = (match[:patch_version] || '0').to_i
  @build_number = (match[:build_number] || '0').to_i
end

Instance Attribute Details

#build_numberObject

Returns the value of attribute build_number.



12
13
14
# File 'lib/fastlane/plugin/goodify_info_plist/helper/version_helper.rb', line 12

def build_number
  @build_number
end

#major_versionObject

Returns the value of attribute major_version.



6
7
8
# File 'lib/fastlane/plugin/goodify_info_plist/helper/version_helper.rb', line 6

def major_version
  @major_version
end

#minor_versionObject

Returns the value of attribute minor_version.



8
9
10
# File 'lib/fastlane/plugin/goodify_info_plist/helper/version_helper.rb', line 8

def minor_version
  @minor_version
end

#patch_versionObject

Returns the value of attribute patch_version.



10
11
12
# File 'lib/fastlane/plugin/goodify_info_plist/helper/version_helper.rb', line 10

def patch_version
  @patch_version
end

Instance Method Details

#<=>(other) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fastlane/plugin/goodify_info_plist/helper/version_helper.rb', line 27

def <=>(other)
  major_version_comparison = self.major_version <=> other.major_version
  minor_version_comparison = self.minor_version <=> other.minor_version
  patch_version_comparison = self.patch_version <=> other.patch_version
  build_number_comparison = self.build_number <=> other.build_number

  if !major_version_comparison.zero?
    major_version_comparison
  elsif !minor_version_comparison.zero?
    minor_version_comparison
  elsif !patch_version_comparison.zero?
    patch_version_comparison
  elsif !build_number_comparison.zero?
    build_number_comparison
  else
    0
  end
end

#to_sObject



23
24
25
# File 'lib/fastlane/plugin/goodify_info_plist/helper/version_helper.rb', line 23

def to_s
  "#{@major_version}.#{@minor_version}.#{@patch_version}.#{@build_number}"
end