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.



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

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

Instance Attribute Details

#majorObject (readonly)

Returns the value of attribute major.



25
26
27
# File 'lib/u3d_core/version.rb', line 25

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



25
26
27
# File 'lib/u3d_core/version.rb', line 25

def minor
  @minor
end

#patchObject (readonly)

Returns the value of attribute patch.



25
26
27
# File 'lib/u3d_core/version.rb', line 25

def patch
  @patch
end

Instance Method Details

#<=>(other) ⇒ Object



39
40
41
42
43
# File 'lib/u3d_core/version.rb', line 39

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

#to_aObject



31
32
33
# File 'lib/u3d_core/version.rb', line 31

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

#to_sObject



35
36
37
# File 'lib/u3d_core/version.rb', line 35

def to_s
  to_a.join('.')
end