Class: Fastlane::Actions::Version

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/fastlane/plugin/gitlab_get_max_version_branch/actions/gitlab_get_max_version_branch_action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version_str) ⇒ Version

Returns a new instance of Version.



10
11
12
13
# File 'lib/fastlane/plugin/gitlab_get_max_version_branch/actions/gitlab_get_max_version_branch_action.rb', line 10

def initialize(version_str)
  @full_version = version_str
  @major, @minor, @patch = version_str.strip.gsub('master_', '').split('.').map(&:to_i)
end

Instance Attribute Details

#full_versionObject (readonly)

Returns the value of attribute full_version.



8
9
10
# File 'lib/fastlane/plugin/gitlab_get_max_version_branch/actions/gitlab_get_max_version_branch_action.rb', line 8

def full_version
  @full_version
end

#majorObject (readonly)

Returns the value of attribute major.



8
9
10
# File 'lib/fastlane/plugin/gitlab_get_max_version_branch/actions/gitlab_get_max_version_branch_action.rb', line 8

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



8
9
10
# File 'lib/fastlane/plugin/gitlab_get_max_version_branch/actions/gitlab_get_max_version_branch_action.rb', line 8

def minor
  @minor
end

#patchObject (readonly)

Returns the value of attribute patch.



8
9
10
# File 'lib/fastlane/plugin/gitlab_get_max_version_branch/actions/gitlab_get_max_version_branch_action.rb', line 8

def patch
  @patch
end

Instance Method Details

#<=>(other) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fastlane/plugin/gitlab_get_max_version_branch/actions/gitlab_get_max_version_branch_action.rb', line 15

def <=>(other)
  return nil unless other.is_a?(Version)

  [
    @major <=> other.major,
    @minor <=> other.minor,
    @patch <=> other.patch
  ].detect do |num|
    !num.zero?
  end || 0
end

#to_sObject



27
28
29
# File 'lib/fastlane/plugin/gitlab_get_max_version_branch/actions/gitlab_get_max_version_branch_action.rb', line 27

def to_s
  @full_version
end