Sha256: 483a23e308dd70e50fe7497e590ce44992f375f9b350ffcbee9b236b39aca6a7

Contents?: true

Size: 915 Bytes

Versions: 7

Compression:

Stored size: 915 Bytes

Contents

module CMSScanner
  # Version
  class Version
    include Finders::Finding

    attr_reader :number

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

      parse_finding_options(opts)
    end

    # @param [ Version, String ] other
    # rubocop:disable Style/NumericPredicate
    def ==(other)
      (self <=> other) == 0
    end
    # rubocop:enable all

    # @param [ Version, String ] other
    def <(other)
      (self <=> other) == -1
    end

    # @param [ Version, String ] other
    def >(other)
      (self <=> other) == 1
    end

    # @param [ Version, String ] other
    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

    def to_s
      number
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cms_scanner-0.0.37.12 app/models/version.rb
cms_scanner-0.0.37.11 app/models/version.rb
cms_scanner-0.0.37.10 app/models/version.rb
cms_scanner-0.0.37.9 app/models/version.rb
cms_scanner-0.0.37.8 app/models/version.rb
cms_scanner-0.0.37.7 app/models/version.rb
cms_scanner-0.0.37.6 app/models/version.rb