Class: Xezat::Cygversion

Inherits:
Object
  • Object
show all
Defined in:
lib/xezat/cygversion.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Cygversion

Returns a new instance of Cygversion.



9
10
11
12
13
14
15
16
# File 'lib/xezat/cygversion.rb', line 9

def initialize(str)
  matched = str.match(/(.+)-(.+)/)
  version = matched[1]
  @release = matched[2]
  split = version.split('+')
  @version = split[0].tr('_', '.')
  @revision = split.length >= 2 ? split[1].match(/(\d+)/)[0].to_i : Time.at(0).strftime('%Y%m%d').to_i
end

Instance Attribute Details

#versionObject (readonly)

Returns the value of attribute version.



7
8
9
# File 'lib/xezat/cygversion.rb', line 7

def version
  @version
end

Instance Method Details

#<=>(other) ⇒ Object



28
29
30
31
32
33
# File 'lib/xezat/cygversion.rb', line 28

def <=>(other)
  result = (to_v <=> other.to_v)
  return result unless result.nil?

  (to_a <=> other.to_a)
end

#to_aObject



24
25
26
# File 'lib/xezat/cygversion.rb', line 24

def to_a
  [@version, @revision, @release]
end

#to_vObject



18
19
20
21
22
# File 'lib/xezat/cygversion.rb', line 18

def to_v
  [Gem::Version.new(@version), @revision, @release]
rescue ArgumentError
  to_a
end