Class: CMSScanner::Model::Version

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

Overview

Version

Constant Summary

Constants included from Finders::Finding

Finders::Finding::FINDING_OPTS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Finders::Finding

#confidence, #confidence=, #confirmed_by, #eql?, included, #interesting_entries, #parse_finding_options

Constructor Details

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

Returns a new instance of Version.



11
12
13
14
15
16
# File 'app/models/version.rb', line 11

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.



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

def number
  @number
end

Instance Method Details

#<(other) ⇒ Object

Parameters:



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

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

#<=>(other) ⇒ Object

Parameters:



36
37
38
39
40
41
42
# File 'app/models/version.rb', line 36

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 ArgumentError
  false
end

#==(other) ⇒ Object

rubocop:disable Style/NumericPredicate

Parameters:



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

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

#>(other) ⇒ Object

Parameters:



31
32
33
# File 'app/models/version.rb', line 31

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

#to_sObject



44
45
46
# File 'app/models/version.rb', line 44

def to_s
  number
end