Sha256: 6810481607f009199113c821e9ed75f988039ce196fbe1ce6c855fa805d8c075
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module Eddy module Element # Alphanumeric string including special characters class AN < Base # @param min [Integer] # @param max [Integer] # @param val [String] # @return [void] def initialize(min, max, val = nil) self.min = min self.max = max self.value = val end # @return [String] def value() # raise Eddy::ElementNilValueError if @value.nil? return @value end # @param arg [String] # @raise [Eddy::ElementValidationError] # @return [void] def value=(arg) if arg.nil? @value = arg return end raise Eddy::ElementValidationError, "value needs to be a string" unless arg.is_a?(String) raise Eddy::ElementValidationError, "value can't be shorter than #{self.min}" if arg.length < self.min raise Eddy::ElementValidationError, "value can't be longer than #{self.max}" if arg.length > self.max @value = arg end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eddy-0.1.0 | lib/eddy/element/an.rb |