Sha256: 71452b9bbf9e79b17e5609a01356cfd1282ad0b9988018fcb99b05cb8392eb9c

Contents?: true

Size: 938 Bytes

Versions: 2

Compression:

Stored size: 938 Bytes

Contents

module DistribBuilder
  module Versioner
    class VersionProcessor
      attr_accessor :major, :minor, :patch, :build

      def initialize(array)
        @major = array[0]
        @minor = array[1]
        @patch = array[2]
        @build = array[3]
      end

      def versions_hash
        {
          major: major,
          minor: minor,
          patch: patch,
          build: build
        }
      end

      # => 0.5.0
      def only_version
        [major, minor, patch].join(".")
      end

      # => 0.5.0.0
      def full_version
        [major, minor, patch, build].join(".")
      end

      def build_up!
        @build += 1
      end

      def build_down!
        return if build == 0
        @build -= 1
      end

      def setup_build!(build)
        @build = build.to_i
      end

      def setup_version!(version)
        @major, @minor, @patch = version.split(".").map{ |d| d.to_i }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
distrib_builder-0.0.3 lib/distrib_builder/versioner/version_processor.rb
distrib_builder-0.0.2 lib/distrib_builder/versioner/version_processor.rb