class VersionCut

Attributes

semver[RW]
value[RW]

Public Class Methods

new(value, segments = nil) click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 6
def initialize(value, segments = nil)
  @value = value.to_s
  if segments.nil?
    @semver = SemanticVersion.new(@value)
  else
    @semver = SemanticVersion.new(@value, segments)
  end
end

Public Instance Methods

!=(other_cut) click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 66
def !=(other_cut)
  # self cannot be BelowAll or AboveAll
  if other_cut.instance_of?(BelowAll) || other_cut.instance_of?(AboveAll)
    false
  else
    @semver != other_cut.semver
  end
end
<(other_cut) click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 41
def <(other_cut)
  other_cut.instance_of?(BelowAll) ? false : other_cut.instance_of?(AboveAll) ? true : @semver < other_cut.semver
end
<=(other_cut) click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 49
def <=(other_cut)
  self < other_cut || self == other_cut
end
==(other_cut) click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 57
def ==(other_cut)
  # self cannot be BelowAll or AboveAll
  if other_cut.instance_of?(BelowAll) || other_cut.instance_of?(AboveAll)
    false
  else
    @semver == other_cut.semver
  end
end
>(other_cut) click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 45
def >(other_cut)
  other_cut.instance_of?(BelowAll) ? true : other_cut.instance_of?(AboveAll) ? false : @semver > other_cut.semver
end
>=(other_cut) click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 53
def >=(other_cut)
  self > other_cut || self == other_cut
end
cross_total() click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 91
def cross_total
  [minor, major, patch].reject { |i| i.empty? }.map { |i| i.to_i }.inject(0) { |sum, x| sum + x }
end
diff(other_cut, abs = true) click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 19
def diff(other_cut, abs = true)
  if other_cut.instance_of?(BelowAll)
    AboveAll.new()
  elsif other_cut.instance_of?(AboveAll)
    BelowAll.new()
  else
    diff = self.semver.diff(other_cut.semver, abs)
    if diff.nil?
      EmptyInterval.new()
    else
      VersionCut.new(diff.join("."), diff)
    end
  end
end
is_initial_version?() click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 75
def is_initial_version?
  @semver.is_zero?
end
is_successor_of?(other_cut) click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 34
def is_successor_of?(other_cut)
  return true if other_cut.instance_of?(BelowAll)
  return false if other_cut.instance_of?(AboveAll)

  self.semver.is_successor_of?(other_cut.semver)
end
major() click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 79
def major
  @semver.major
end
minor() click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 83
def minor
  @semver.minor
end
patch() click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 87
def patch
  @semver.patch
end
to_s() click to toggle source
# File lib/semver_dialects/semantic_version/version_cut.rb, line 15
def to_s
  @value.to_s
end