Class: Nauvisian::Version64
- Inherits:
-
Object
- Object
- Nauvisian::Version64
- Includes:
- Comparable
- Defined in:
- lib/nauvisian/version64.rb
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(*args) ⇒ Version64
constructor
A new instance of Version64.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ Version64
Returns a new instance of Version64.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nauvisian/version64.rb', line 10 def initialize(*args) case args in [String] if /\A(\d+)\.(\d+)\.(\d+)(?:-(\d+))?\z/ =~ args[0] @version = [Integer($1), Integer($2), Integer($3), $4.nil? ? 0 : Integer($4)] in [Integer, Integer, Integer, Integer] if args.all? {|e| e.is_a?(Numeric) && e.integer? && e.between?(0, UINT16_MAX) } @version = args else raise ArgumentError, "Expect version string or 4-tuple: %p" % [args] end @version.freeze freeze end |
Instance Method Details
#<=>(other) ⇒ Object
31 |
# File 'lib/nauvisian/version64.rb', line 31 def <=>(other) = @version <=> other.version |
#to_a ⇒ Object
30 |
# File 'lib/nauvisian/version64.rb', line 30 def to_a = @version.dup.freeze |
#to_s ⇒ Object
29 |
# File 'lib/nauvisian/version64.rb', line 29 def to_s = "%d.%d.%d-%d" % @version |