Sha256: 3315b4a216e9d73c5c8f8f89aef4060667761abe12308b22a561b9cb9eff4a73

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

module Gris
  VERSION = '0.4.9'

  class Version
    class << self
      def next_major
        next_level(:major)
      end

      def next_minor
        next_level(:minor)
      end

      def next_patch
        next_level(:patch)
      end

      def next_level(level)
        fail 'Unidentified Level' unless [:major, :minor, :patch].include?(level)
        parts = Gris::VERSION.split('.').map(&:to_i)
        if level == :major
          parts[0] += 1
          significant_index = 1
        end
        if level == :minor
          parts[1] += 1
          significant_index = 2
        end
        if level == :patch
          parts[2] += 1
          significant_index = 3
        end
        parts.map.with_index { |_p, i| parts[i] = 0 if i >= significant_index }
        parts.join('.')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gris-0.4.9 lib/gris/version.rb