Sha256: 29f7d1fe3ecb1869b233d4688e799a7c3603d299bc4578baadc3b5fe25e6e410

Contents?: true

Size: 929 Bytes

Versions: 25

Compression:

Stored size: 929 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 ArgumentError
      false
    end

    def to_s
      number
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
cms_scanner-0.0.41.10 app/models/version.rb
cms_scanner-0.0.41.9 app/models/version.rb
cms_scanner-0.0.41.8 app/models/version.rb
cms_scanner-0.0.41.7 app/models/version.rb
cms_scanner-0.0.41.6 app/models/version.rb
cms_scanner-0.0.41.5 app/models/version.rb
cms_scanner-0.0.41.4 app/models/version.rb
cms_scanner-0.0.41.3 app/models/version.rb
cms_scanner-0.0.41.2 app/models/version.rb
cms_scanner-0.0.41.1 app/models/version.rb
cms_scanner-0.0.41.0 app/models/version.rb
cms_scanner-0.0.40.3 app/models/version.rb
cms_scanner-0.0.40.2 app/models/version.rb
cms_scanner-0.0.40.1 app/models/version.rb
cms_scanner-0.0.40 app/models/version.rb
cms_scanner-0.0.39.4 app/models/version.rb
cms_scanner-0.0.39.3 app/models/version.rb
cms_scanner-0.0.39.2 app/models/version.rb
cms_scanner-0.0.39.1 app/models/version.rb
cms_scanner-0.0.39.0 app/models/version.rb