Class: Nucleo::Models::Concerns::Count

Inherits:
Object
  • Object
show all
Defined in:
lib/nucleo/models/concerns/count.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(count, min, max) ⇒ Nucleo::Concerns::Count

Returns an instance of the Count concern domain model

Parameters:

  • total (Integer)
  • min (Integer)
  • max (Integer)


14
15
16
17
18
# 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

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



5
6
7
# File 'lib/nucleo/models/concerns/count.rb', line 5

def count
  @count
end

#maxObject (readonly)

Returns the value of attribute max.



5
6
7
# File 'lib/nucleo/models/concerns/count.rb', line 5

def max
  @max
end

#minObject (readonly)

Returns the value of attribute min.



5
6
7
# File 'lib/nucleo/models/concerns/count.rb', line 5

def min
  @min
end

Instance Method Details

#max?Boolean

Returns true if there is a max

Returns:

  • (Boolean)


44
45
46
# File 'lib/nucleo/models/concerns/count.rb', line 44

def max?
  (self.max > 0)
end

#missing?Boolean

Returns true if missing

Returns:

  • (Boolean)


23
24
25
# File 'lib/nucleo/models/concerns/count.rb', line 23

def missing?
  (self.count < 1)
end

#multiple?Boolean

Returns true if multiple

Returns:

  • (Boolean)


30
31
32
# File 'lib/nucleo/models/concerns/count.rb', line 30

def multiple?
  (self.count > 1)
end

#too_few?Boolean

Returns true if too few

Returns:

  • (Boolean)


37
38
39
# File 'lib/nucleo/models/concerns/count.rb', line 37

def too_few?
  (self.count < self.min)
end

#too_many?Boolean

Returns true if there is too many

Returns:

  • (Boolean)


51
52
53
# File 'lib/nucleo/models/concerns/count.rb', line 51

def too_many?
  (self.max? && (self.count > self.max))
end