class Nucleo::Models::Concerns::Length
Attributes
length[R]
max[R]
min[R]
Public Class Methods
new(length, min, max)
click to toggle source
Returns an instance of the Length
concern domain model
@param length [Integer] @param min [Integer] @param max [Integer]
@return [Nucleo::Concerns::Length]
# File lib/nucleo/models/concerns/length.rb, line 14 def initialize(length, min, max) @length = length.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/length.rb, line 23 def max? (self.max > 0) end
too_long?()
click to toggle source
Returns true if too long
@return [Boolean]
# File lib/nucleo/models/concerns/length.rb, line 44 def too_long? (self.max? && (self.length > self.max)) end
too_long_length()
click to toggle source
Returns the too long length
@return [Integer]
# File lib/nucleo/models/concerns/length.rb, line 51 def too_long_length (self.length - self.max) end
too_short?()
click to toggle source
Returns true if too short
@return [Boolean]
# File lib/nucleo/models/concerns/length.rb, line 30 def too_short? (self.length <= self.min) end
too_short_length()
click to toggle source
Returns the too short length
@return [Integer]
# File lib/nucleo/models/concerns/length.rb, line 37 def too_short_length (self.min - self.length) end