Class: Xezat::Cygversion

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

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Cygversion

Returns a new instance of Cygversion.



5
6
7
8
9
10
11
12
# File 'lib/xezat/cygversion.rb', line 5

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

Instance Method Details

#<=>(operand) ⇒ Object



22
23
24
# File 'lib/xezat/cygversion.rb', line 22

def <=>(operand)
  to_v <=> operand.to_v
end

#to_aObject



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

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

#to_vObject



14
15
16
# File 'lib/xezat/cygversion.rb', line 14

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