Class: CMSScanner::Version
- Inherits:
-
Object
- Object
- CMSScanner::Version
- Defined in:
- app/models/version.rb
Overview
Version
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Instance Method Summary collapse
- #<(other) ⇒ Object
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #>(other) ⇒ Object
-
#initialize(number, opts = {}) ⇒ Version
constructor
A new instance of Version.
- #to_s ⇒ Object
Constructor Details
#initialize(number, opts = {}) ⇒ Version
Returns a new instance of Version.
8 9 10 11 12 13 |
# File 'app/models/version.rb', line 8 def initialize(number, opts = {}) @number = number.to_s @number = "0#{number}" if @number[0, 1] == '.' (opts) end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
6 7 8 |
# File 'app/models/version.rb', line 6 def number @number end |
Instance Method Details
#<(other) ⇒ Object
21 22 23 |
# File 'app/models/version.rb', line 21 def <(other) (self <=> other) == -1 end |
#<=>(other) ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/models/version.rb', line 31 def <=>(other) other = self.class.new(other) unless other.is_a?(self.class) # handle potential '.1' version Gem::Version.new(number) <=> Gem::Version.new(other.number) rescue false end |
#==(other) ⇒ Object
16 17 18 |
# File 'app/models/version.rb', line 16 def ==(other) (self <=> other) == 0 end |
#>(other) ⇒ Object
26 27 28 |
# File 'app/models/version.rb', line 26 def >(other) (self <=> other) == 1 end |
#to_s ⇒ Object
39 40 41 |
# File 'app/models/version.rb', line 39 def to_s number end |