module VersionGem::Api

Public API of this library

Public Instance Methods

major() click to toggle source

The major version

@return [Integer]

# File lib/version_gem/api.rb, line 14
def major
  @major ||= _to_a[0].to_i
end
minor() click to toggle source

The minor version

@return [Integer]

# File lib/version_gem/api.rb, line 21
def minor
  @minor ||= _to_a[1].to_i
end
patch() click to toggle source

The patch version

@return [Integer]

# File lib/version_gem/api.rb, line 28
def patch
  @patch ||= _to_a[2].to_i
end
pre() click to toggle source

The pre-release version, if any

@return [String, NilClass]

# File lib/version_gem/api.rb, line 35
def pre
  @pre ||= _to_a[3]
end
to_a() click to toggle source

The version number as an array of cast values

@return [Array<[Integer, String, NilClass]>]

# File lib/version_gem/api.rb, line 54
def to_a
  @to_a ||= [major, minor, patch, pre]
end
to_h() click to toggle source

The version number as a hash

@return [Hash]

# File lib/version_gem/api.rb, line 42
def to_h
  @to_h ||= {
    major: major,
    minor: minor,
    patch: patch,
    pre: pre,
  }
end
to_s() click to toggle source

The version number as a string

@return [String]

# File lib/version_gem/api.rb, line 7
def to_s
  self::VERSION
end

Private Instance Methods

_to_a() click to toggle source

The version number as an array of strings

@return [Array<String>]

# File lib/version_gem/api.rb, line 63
def _to_a
  @_to_a = self::VERSION.split(".")
end