Module: VersionGem::Api

Defined in:
lib/version_gem/api.rb

Overview

Public API of this library

Instance Method Summary collapse

Instance Method Details

#majorInteger

The major version

Returns:

  • (Integer)


14
15
16
# File 'lib/version_gem/api.rb', line 14

def major
  @major ||= _to_a[0].to_i
end

#minorInteger

The minor version

Returns:

  • (Integer)


21
22
23
# File 'lib/version_gem/api.rb', line 21

def minor
  @minor ||= _to_a[1].to_i
end

#patchInteger

The patch version

Returns:

  • (Integer)


28
29
30
# File 'lib/version_gem/api.rb', line 28

def patch
  @patch ||= _to_a[2].to_i
end

#preString, NilClass

The pre-release version, if any

Returns:

  • (String, NilClass)


35
36
37
# File 'lib/version_gem/api.rb', line 35

def pre
  @pre ||= _to_a[3]
end

#to_aArray<[Integer, String, NilClass]>

The version number as an array of cast values

Returns:

  • (Array<[Integer, String, NilClass]>)


54
55
56
# File 'lib/version_gem/api.rb', line 54

def to_a
  @to_a ||= [major, minor, patch, pre]
end

#to_hHash

The version number as a hash

Returns:

  • (Hash)


42
43
44
45
46
47
48
49
# File 'lib/version_gem/api.rb', line 42

def to_h
  @to_h ||= {
    major: major,
    minor: minor,
    patch: patch,
    pre: pre,
  }
end

#to_sString

The version number as a string

Returns:

  • (String)


7
8
9
# File 'lib/version_gem/api.rb', line 7

def to_s
  self::VERSION
end