Class: Nucleo::Models::Concerns::Count
- Inherits:
-
Object
- Object
- Nucleo::Models::Concerns::Count
- Defined in:
- lib/nucleo/models/concerns/count.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
Instance Method Summary collapse
-
#initialize(count, min, max) ⇒ Nucleo::Concerns::Count
constructor
Returns an instance of the Count concern domain model.
-
#max? ⇒ Boolean
Returns true if there is a max.
-
#missing? ⇒ Boolean
Returns true if missing.
-
#multiple? ⇒ Boolean
Returns true if multiple.
-
#too_few? ⇒ Boolean
Returns true if too few.
-
#too_many? ⇒ Boolean
Returns true if there is too many.
Constructor Details
#initialize(count, min, max) ⇒ Nucleo::Concerns::Count
Returns an instance of the Count concern domain model
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
#count ⇒ Object (readonly)
Returns the value of attribute count.
5 6 7 |
# File 'lib/nucleo/models/concerns/count.rb', line 5 def count @count end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
5 6 7 |
# File 'lib/nucleo/models/concerns/count.rb', line 5 def max @max end |
#min ⇒ Object (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
44 45 46 |
# File 'lib/nucleo/models/concerns/count.rb', line 44 def max? (self.max > 0) end |
#missing? ⇒ Boolean
Returns true if missing
23 24 25 |
# File 'lib/nucleo/models/concerns/count.rb', line 23 def missing? (self.count < 1) end |
#multiple? ⇒ Boolean
Returns true if multiple
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
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
51 52 53 |
# File 'lib/nucleo/models/concerns/count.rb', line 51 def too_many? (self.max? && (self.count > self.max)) end |