Class: MRuby::Gem::Version
Overview
Constant Summary
Constants included
from Enumerable
Enumerable::NONE
Instance Method Summary
collapse
Methods included from Enumerable
#all?, #any?, #chain, #collect, #count, #cycle, #detect, #drop, #drop_while, #each_cons, #each_slice, #each_with_index, #each_with_object, #entries, #filter_map, #find_all, #find_index, #first, #flat_map, #grep, #group_by, #hash, #include?, #inject, #lazy, #max, #max_by, #min, #min_by, #minmax, #minmax_by, #none?, #one?, #partition, #reject, #reverse_each, #sort, #sort_by, #take, #take_while, #tally, #to_h, #uniq, #zip
Methods included from Comparable
#<, #<=, #==, #>, #>=, #between?, #clamp
Constructor Details
#initialize(str) ⇒ Version
298
299
300
301
|
# File 'ext/enterprise_script_service/mruby/lib/mruby/gem.rb', line 298
def initialize(str)
@str = str
@ary = @str.split('.').map(&:to_i)
end
|
Instance Method Details
#<=>(other) ⇒ Object
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
# File 'ext/enterprise_script_service/mruby/lib/mruby/gem.rb', line 261
def <=>(other)
ret = 0
own = to_enum
other.each do |oth|
begin
ret = own.next <=> oth
rescue StopIteration
ret = 0 <=> oth
end
break unless ret == 0
end
ret
end
|
#[](index) ⇒ Object
304
|
# File 'ext/enterprise_script_service/mruby/lib/mruby/gem.rb', line 304
def [](index); @ary[index]; end
|
#[]=(index, value) ⇒ Object
305
306
307
308
|
# File 'ext/enterprise_script_service/mruby/lib/mruby/gem.rb', line 305
def []=(index, value)
@ary[index] = value
@str = @ary.join('.')
end
|
#each(&block) ⇒ Object
303
|
# File 'ext/enterprise_script_service/mruby/lib/mruby/gem.rb', line 303
def each(&block); @ary.each(&block); end
|
#skip_major_or_minor ⇒ Object
290
291
292
293
294
295
296
|
# File 'ext/enterprise_script_service/mruby/lib/mruby/gem.rb', line 290
def skip_major_or_minor
a = @ary.dup
a << 0 if a.size == 1
a.slice!(-1)
a[-1] = a[-1].succ
a
end
|
#slice!(index) ⇒ Object
309
310
311
312
|
# File 'ext/enterprise_script_service/mruby/lib/mruby/gem.rb', line 309
def slice!(index)
@ary.slice!(index)
@str = @ary.join('.')
end
|
#twiddle_wakka_ok?(other) ⇒ Boolean
~> compare algorithm
Example:
~> 2 means >= 2.0.0 and < 3.0.0
~> 2.2 means >= 2.2.0 and < 3.0.0
~> 2.2.2 means >= 2.2.2 and < 2.3.0
284
285
286
287
288
|
# File 'ext/enterprise_script_service/mruby/lib/mruby/gem.rb', line 284
def twiddle_wakka_ok?(other)
gr_or_eql = (self <=> other) >= 0
still_major_or_minor = (self <=> other.skip_major_or_minor) < 0
gr_or_eql and still_major_or_minor
end
|