class Nucleo::Models::Concerns::Count

Attributes

count[R]
max[R]
min[R]

Public Class Methods

new(count, min, max) click to toggle source

Returns an instance of the Count concern domain model

@param total [Integer] @param min [Integer] @param max [Integer]

@return [Nucleo::Concerns::Count]

# File lib/nucleo/models/concerns/count.rb, line 14
def initialize(count, min, max)
  @count = count.to_i
  @min   = min.to_i
  @max   = max.to_i
end

Public Instance Methods

max?() click to toggle source

Returns true if there is a max

@return [Boolean]

# File lib/nucleo/models/concerns/count.rb, line 44
def max?
  (self.max > 0)
end
missing?() click to toggle source

Returns true if missing

@return [Boolean]

# File lib/nucleo/models/concerns/count.rb, line 23
def missing?
  (self.count < 1)
end
multiple?() click to toggle source

Returns true if multiple

@return [Boolean]

# File lib/nucleo/models/concerns/count.rb, line 30
def multiple?
  (self.count > 1)
end
too_few?() click to toggle source

Returns true if too few

@return [Boolean]

# File lib/nucleo/models/concerns/count.rb, line 37
def too_few?
  (self.count < self.min)
end
too_many?() click to toggle source

Returns true if there is too many

@return [Boolean]

# File lib/nucleo/models/concerns/count.rb, line 51
def too_many?
  (self.max? && (self.count > self.max))
end