Class: ForemanFogProxmox::Semver::SemverClass
- Inherits:
-
Object
- Object
- ForemanFogProxmox::Semver::SemverClass
- Defined in:
- lib/foreman_fog_proxmox/semver.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
Returns the value of attribute major.
-
#minor ⇒ Object
Returns the value of attribute minor.
-
#patch ⇒ Object
Returns the value of attribute patch.
-
#qualifier ⇒ Object
Returns the value of attribute qualifier.
Instance Method Summary collapse
- #<(other) ⇒ Object
- #<=(other) ⇒ Object
- #==(other) ⇒ Object
- #>(other) ⇒ Object
- #>=(other) ⇒ Object
-
#initialize(major, minor, patch, qualifier = '') ⇒ SemverClass
constructor
A new instance of SemverClass.
- #to_s ⇒ Object
Constructor Details
#initialize(major, minor, patch, qualifier = '') ⇒ SemverClass
Returns a new instance of SemverClass.
26 27 28 29 30 31 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 26 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
#major ⇒ Object
Returns the value of attribute major.
24 25 26 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 24 def major @major end |
#minor ⇒ Object
Returns the value of attribute minor.
24 25 26 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 24 def minor @minor end |
#patch ⇒ Object
Returns the value of attribute patch.
24 25 26 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 24 def patch @patch end |
#qualifier ⇒ Object
Returns the value of attribute qualifier.
24 25 26 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 24 def qualifier @qualifier end |
Instance Method Details
#<(other) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 48 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
39 40 41 42 43 44 45 46 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 39 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
75 76 77 78 79 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 75 def ==(other) raise TypeError unless other.is_a?(SemverClass) @major == other.major && @minor == other.minor && @patch == other.patch && @qualifier == other.qualifier end |
#>(other) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 57 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
66 67 68 69 70 71 72 73 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 66 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_s ⇒ Object
33 34 35 36 37 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 33 def to_s flat = "#{major}.#{minor}.#{patch}" flat += "-#{qualifier}" unless qualifier == '' flat end |