Class: U3dCore::Version

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/u3d_core/version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ Version

Returns a new instance of Version.



29
30
31
# File 'lib/u3d_core/version.rb', line 29

def initialize(version)
  @major, @minor, @patch = version.split('.').map(&:to_i)
end

Instance Attribute Details

#majorObject (readonly)

Returns the value of attribute major.



27
28
29
# File 'lib/u3d_core/version.rb', line 27

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



27
28
29
# File 'lib/u3d_core/version.rb', line 27

def minor
  @minor
end

#patchObject (readonly)

Returns the value of attribute patch.



27
28
29
# File 'lib/u3d_core/version.rb', line 27

def patch
  @patch
end

Instance Method Details

#<=>(other) ⇒ Object



41
42
43
44
45
# File 'lib/u3d_core/version.rb', line 41

def <=>(other)
  (major <=> other.major).nonzero? ||
    (minor <=> other.minor).nonzero? ||
    patch <=> other.patch
end

#to_aObject



33
34
35
# File 'lib/u3d_core/version.rb', line 33

def to_a
  [major, minor, patch].compact
end

#to_sObject



37
38
39
# File 'lib/u3d_core/version.rb', line 37

def to_s
  to_a.join('.')
end