Class: ForemanFogProxmox::Semver::SemverClass

Inherits:
Object
  • Object
show all
Defined in:
lib/foreman_fog_proxmox/semver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(major, minor, patch, qualifier = '') ⇒ SemverClass

Returns a new instance of SemverClass.



29
30
31
32
33
34
# File 'lib/foreman_fog_proxmox/semver.rb', line 29

def initialize(major, minor, patch, qualifier = '')
  @major = major.to_i
  @minor = minor.to_i
  @patch = patch.to_i
  @qualifier = qualifier.nil? ? '' : qualifier
end

Instance Attribute Details

#majorObject

Returns the value of attribute major.



24
25
26
# File 'lib/foreman_fog_proxmox/semver.rb', line 24

def major
  @major
end

#minorObject

Returns the value of attribute minor.



25
26
27
# File 'lib/foreman_fog_proxmox/semver.rb', line 25

def minor
  @minor
end

#patchObject

Returns the value of attribute patch.



26
27
28
# File 'lib/foreman_fog_proxmox/semver.rb', line 26

def patch
  @patch
end

#qualifierObject

Returns the value of attribute qualifier.



27
28
29
# File 'lib/foreman_fog_proxmox/semver.rb', line 27

def qualifier
  @qualifier
end

Instance Method Details

#<(other) ⇒ Object

Raises:

  • (TypeError)


51
52
53
54
55
56
57
58
# File 'lib/foreman_fog_proxmox/semver.rb', line 51

def <(other)
  raise TypeError unless other.is_a?(SemverClass)

  result = @major < other.major
  result = @minor < other.minor if @major == other.major
  result = @patch < other.patch if @minor == other.minor && @major == other.major
  result
end

#<=(other) ⇒ Object

Raises:

  • (TypeError)


42
43
44
45
46
47
48
49
# File 'lib/foreman_fog_proxmox/semver.rb', line 42

def <=(other)
  raise TypeError unless other.is_a?(SemverClass)

  result = @major <= other.major
  result = @minor <= other.minor if @major == other.major
  result = @patch <= other.patch if @minor == other.minor && @major == other.major
  result
end

#==(other) ⇒ Object

Raises:

  • (TypeError)


78
79
80
81
82
# File 'lib/foreman_fog_proxmox/semver.rb', line 78

def ==(other)
  raise TypeError unless other.is_a?(SemverClass)

  @major == other.major && @minor == other.minor && @patch == other.patch && @qualifier == other.qualifier
end

#>(other) ⇒ Object

Raises:

  • (TypeError)


60
61
62
63
64
65
66
67
# File 'lib/foreman_fog_proxmox/semver.rb', line 60

def >(other)
  raise TypeError unless other.is_a?(SemverClass)

  result = @major > other.major
  result = @minor > other.minor if @major == other.major
  result = @patch > other.patch if @minor == other.minor && @major == other.major
  result
end

#>=(other) ⇒ Object

Raises:

  • (TypeError)


69
70
71
72
73
74
75
76
# File 'lib/foreman_fog_proxmox/semver.rb', line 69

def >=(other)
  raise TypeError unless other.is_a?(SemverClass)

  result = @major >= other.major
  result = @minor >= other.minor if @major == other.major
  result = @patch >= other.patch if @minor == other.minor && @major == other.major
  result
end

#to_sObject



36
37
38
39
40
# File 'lib/foreman_fog_proxmox/semver.rb', line 36

def to_s
  flat = "#{major}.#{minor}.#{patch}"
  flat += "-#{qualifier}" unless qualifier == ''
  flat
end