Module: VersionGem::Epoch::OverloadApiForEpoch

Defined in:
lib/version_gem/epoch.rb

Overview

Tweak the basic API so it will support Epoch Semantic Versioning

Instance Method Summary collapse

Instance Method Details

#epochInteger

*** OVERLOAD METHODS FROM API ***

The epoch version

Returns:

  • (Integer)


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

def epoch
  @epoch ||= _major / EPOCH_SIZE
end

#majorInteger

The major version

Returns:

  • (Integer)


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

def major
  @major ||= _major % EPOCH_SIZE
end

#to_aArray<[Integer, String, NilClass]>

NOTE: This is not the same as _to_a, which returns an array of strings

The version number as an array of cast values where epoch and major are derived from a single string:

EPOCH * 1000 + MAJOR

Returns:

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


59
60
61
# File 'lib/version_gem/epoch.rb', line 59

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

#to_hHash

The version number as a hash

Returns:

  • (Hash)


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

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