class AssUpdater::AssVersion
Class implement 1C version numbering. 1C version consist from 4 digt group. Major 1st and 2nd group called Redaction.
Attributes
Value of digit group @return [Fixrnum]
Value of digit group @return [Fixrnum]
Value of digit group @return [Fixrnum]
Value of digit group @return [Fixrnum]
Public Class Methods
Convert [Array<String>] to [Array<AssUpdater::AssVersion>] @return [Array<AssUpdater::AssVersion>]
# File lib/ass_updater/ass_version.rb, line 18 def convert_array(a) a.map do |i| new(i) end end
@param v [String AssUpdater::AssVersion] if not given return
{.zerro_version}
# File lib/ass_updater/ass_version.rb, line 33 def initialize(v = nil) v ||= '0.0.0.0' unless v.to_s =~ /^(\d)+\.(\d+)\.(\d+)\.(\d+)$/ fail ArgumentError, "Invalid version string `#{v}'. Expect 'd.d.d.d' format" end @_1 = Regexp.last_match(1).to_i @_2 = Regexp.last_match(2).to_i @_3 = Regexp.last_match(3).to_i @_4 = Regexp.last_match(4).to_i end
Return zerro vesion number '0.0.0.0' @return [AssUpdater::AssVersion]
# File lib/ass_updater/ass_version.rb, line 12 def zerro_version new('0.0.0.0') end
Public Instance Methods
(see #<=>)
# File lib/ass_updater/ass_version.rb, line 87 def <(other) (self <=> other) == -1 end
(see #<=>)
# File lib/ass_updater/ass_version.rb, line 97 def <=(other) (self <=> other) <= 0 end
Compare versions @return [Boollean]
# File lib/ass_updater/ass_version.rb, line 65 def <=>(other) merge(other).each do |v| if v[0] > v[1] return 1 elsif v[0] < v[1] return -1 end end 0 end
(see #<=>)
# File lib/ass_updater/ass_version.rb, line 77 def ==(other) (self <=> other) == 0 end
(see #<=>)
# File lib/ass_updater/ass_version.rb, line 82 def >(other) (self <=> other) == 1 end
(see #<=>)
# File lib/ass_updater/ass_version.rb, line 92 def >=(other) (self <=> other) >= 0 end
Return redaction number @return [String]
# File lib/ass_updater/ass_version.rb, line 59 def redaction to_a.shift(2).join('.') end
Conver version to array of digit group @return [Array<Fixnum>]
# File lib/ass_updater/ass_version.rb, line 47 def to_a [@_1, @_2, @_3, @_4] end
Convert version to string @return [Stgring]
# File lib/ass_updater/ass_version.rb, line 53 def to_s to_a.join('.') end
Return true if it is zerro version see {.zerro_version}
# File lib/ass_updater/ass_version.rb, line 27 def zerro? to_s == '0.0.0.0' end
Private Instance Methods
# File lib/ass_updater/ass_version.rb, line 103 def merge(o) to_a.zip o.to_a end