module VersionGem::Api

Public Instance Methods

major() click to toggle source

The major version

@return [Integer]

# File lib/version_gem/api.rb, line 13
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 20
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 27
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 34
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 53
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 41
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 6
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 62
def _to_a
  @_to_a = self::VERSION.split('.')
end