Module: VersionGem::Epoch::OverloadApiForEpoch

Defined in:
lib/version_gem/epoch.rb,
sig/version_gem/epoch.rbs

Overview

Tweak the basic API so it will support Epoch Semantic Versioning

Instance Method Summary collapse

Instance Method Details

#_majorInteger

Returns:

  • (Integer)


65
66
67
# File 'lib/version_gem/epoch.rb', line 65

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

#epochInteger

The epoch component (derived)

Returns:

  • (Integer)


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

def epoch
  @epoch ||= _major / EPOCH_SIZE
end

#majorInteger

Override of Api#major returning the derived major component

Returns:

  • (Integer)


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

def major
  @major ||= _major % EPOCH_SIZE
end

#to_aArray[Integer | String | nil]

Array of components [epoch, major, minor, patch, pre]

Returns:

  • (Array[Integer | String | nil])


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

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

#to_hHash[Symbol, (Integer | String | nil)]

Hash representation including epoch

Returns:

  • (Hash[Symbol, (Integer | String | nil)])


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