Class: CMSScanner::Version

Inherits:
Object
  • Object
show all
Defined in:
app/models/version.rb

Overview

Version

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number, opts = {}) ⇒ Version

Returns a new instance of Version.



8
9
10
11
12
13
# File 'app/models/version.rb', line 8

def initialize(number, opts = {})
  @number = number.to_s
  @number = "0#{number}" if @number[0, 1] == '.'

  parse_finding_options(opts)
end

Instance Attribute Details

#numberObject (readonly)

Returns the value of attribute number.



6
7
8
# File 'app/models/version.rb', line 6

def number
  @number
end

Instance Method Details

#<(other) ⇒ Object

Parameters:



21
22
23
# File 'app/models/version.rb', line 21

def <(other)
  (self <=> other) == -1
end

#<=>(other) ⇒ Object

Parameters:



31
32
33
34
35
36
37
# File 'app/models/version.rb', line 31

def <=>(other)
  other = self.class.new(other) unless other.is_a?(self.class) # handle potential '.1' version

  Gem::Version.new(number) <=> Gem::Version.new(other.number)
rescue
  false
end

#==(other) ⇒ Object

Parameters:



16
17
18
# File 'app/models/version.rb', line 16

def ==(other)
  (self <=> other) == 0
end

#>(other) ⇒ Object

Parameters:



26
27
28
# File 'app/models/version.rb', line 26

def >(other)
  (self <=> other) == 1
end

#to_sObject



39
40
41
# File 'app/models/version.rb', line 39

def to_s
  number
end