Sha256: 7ab71b2561970af6965d411a518aa6c632903701fcbec47ed84a083e475ed503

Contents?: true

Size: 824 Bytes

Versions: 28

Compression:

Stored size: 824 Bytes

Contents

class ImageOptim
  class BinResolver
    # Allows comparision of simple versions, only numbers separated by dots are
    # taken into account
    class SimpleVersion
      include Comparable

      # Numbers extracted from version string
      attr_reader :parts

      # Initialize with a string or an object convertible to string
      #
      #    SimpleVersion.new('2.0.1') <=> SimpleVersion.new(2)
      def initialize(str)
        @str = String(str)
        @parts = @str.split('.').map(&:to_i).reverse.drop_while(&:zero?).reverse
      end

      # Returns original version string
      def to_s
        @str
      end

      # Compare version parts of self with other
      def <=>(other)
        other = self.class.new(other) unless other.is_a?(self.class)
        parts <=> other.parts
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
image_optim-0.26.3 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.26.2 lib/image_optim/bin_resolver/simple_version.rb
discourse_image_optim-0.26.2 lib/image_optim/bin_resolver/simple_version.rb
discourse_image_optim-0.26.1 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.26.1 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.26.0 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.25.0 lib/image_optim/bin_resolver/simple_version.rb
discourse_image_optim-0.24.5 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.24.3 lib/image_optim/bin_resolver/simple_version.rb
discourse_image_optim-0.24.4 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.24.2 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.24.1 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.24.0 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.23.0 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.22.1 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.22.0 lib/image_optim/bin_resolver/simple_version.rb
openstreetmap-image_optim-0.21.0.1 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.21.0 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.20.2 lib/image_optim/bin_resolver/simple_version.rb
image_optim-0.20.1 lib/image_optim/bin_resolver/simple_version.rb