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