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.



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

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.



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

def major
  @major
end

#minorObject

Returns the value of attribute minor.



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

def minor
  @minor
end

#patchObject

Returns the value of attribute patch.



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

def patch
  @patch
end

#qualifierObject

Returns the value of attribute qualifier.



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

def qualifier
  @qualifier
end

Instance Method Details

#<(other) ⇒ Object

Raises:

  • (TypeError)


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

def <(other)
    raise TypeError unless other.is_a?(SemverClass)
    if @major == other.major
        if @minor == other.minor
            return @patch < other.patch
        else
            return @minor < other.minor
        end
    else
        return @major < other.major
    end
end

#<=(other) ⇒ Object

Raises:

  • (TypeError)


37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/foreman_fog_proxmox/semver.rb', line 37

def <=(other)
    raise TypeError unless other.is_a?(SemverClass)
    if @major == other.major
        if @minor == other.minor
            return @patch <= other.patch
        else
            return @minor <= other.minor
        end
    else
        return @major <= other.major
    end
end

#==(other) ⇒ Object

Raises:

  • (TypeError)


85
86
87
88
# File 'lib/foreman_fog_proxmox/semver.rb', line 85

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)


61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/foreman_fog_proxmox/semver.rb', line 61

def >(other)
    raise TypeError unless other.is_a?(SemverClass)
    if @major == other.major
        if @minor == other.minor
            return @patch > other.patch
        else
            return @minor > other.minor
        end
    else
        return @major > other.major
    end
end

#>=(other) ⇒ Object

Raises:

  • (TypeError)


73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/foreman_fog_proxmox/semver.rb', line 73

def >=(other)
    raise TypeError unless other.is_a?(SemverClass)
    if @major == other.major
        if @minor == other.minor
            return @patch >= other.patch
        else
            return @minor >= other.minor
        end
    else
        return @major >= other.major
    end
end

#to_sObject



33
34
35
36
# File 'lib/foreman_fog_proxmox/semver.rb', line 33

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