Sha256: 61a83dd62feeee8dcf78d495558fced1b6ea1ac566c2ce7d19530656be49b162

Contents?: true

Size: 601 Bytes

Versions: 1

Compression:

Stored size: 601 Bytes

Contents

module Eff
  class Package
    class SemanticVersion
      PARTS = %i(major minor patch release identity)

      PARTS.each do |part|
        attr_accessor part
      end

      def initialize(version_string)
        @version_string = version_string
        parse!
      end

      def to_h
        Hash[
          PARTS.map { |part| [part, send(part)] }
        ]
      end

    private
      def parse!
        remaining, @identity   = @version_string.split("+")
        remaining, @release    = remaining.split("-")
        @major, @minor, @patch = remaining.split(".")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eff-0.0.1 lib/eff/package/semantic_version.rb