Sha256: 4e84831482e23f4b46d5b5e98f31b61d5afb49bbd82687f231d600a4d27f2f90

Contents?: true

Size: 849 Bytes

Versions: 3

Compression:

Stored size: 849 Bytes

Contents

module VersionGem
  module Api
    # The version number as a string
    #
    # @return [String]
    def to_s
      self::VERSION
    end

    # The major version
    #
    # @return [Integer]
    def major
      to_a[0].to_i
    end

    # The minor version
    #
    # @return [Integer]
    def minor
      to_a[1].to_i
    end

    # The patch version
    #
    # @return [Integer]
    def patch
      to_a[2].to_i
    end

    # The pre-release version, if any
    #
    # @return [String, NilClass]
    def pre
      to_a[3]
    end

    # The version number as a hash
    #
    # @return [Hash]
    def to_h
      {
        major: major,
        minor: minor,
        patch: patch,
        pre: pre
      }
    end

    # The version number as an array
    #
    # @return [Array]
    def to_a
      self::VERSION.split('.')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
version_gem-1.0.2 lib/version_gem/api.rb
version_gem-1.0.1 lib/version_gem/api.rb
version_gem-1.0.0 lib/version_gem/api.rb