Sha256: 64862d3ac1dce52b83cd6bff5dd011820dc83199030a8907f1f4fa007f93e393
Contents?: true
Size: 1.58 KB
Versions: 1
Compression:
Stored size: 1.58 KB
Contents
module Eddy module Models module Element # Identifier (works with a code list specified by the dictionary). class ID < Base # @param min [Integer] # @param max [Integer] # @param req [String] (nil) # @param ref [String] (nil) # @param val [String] (nil) # @return [void] def initialize( min:, max:, req: nil, ref: nil, val: nil ) @type = "ID" @min = min @max = max self.req = req self.ref = ref self.value = val end # @raise [Eddy::Errors::ElementNilValueError] If the element is required and no value has been set. # @return [String] def value() if @val.nil? case self.req when "M" then raise Eddy::Errors::ElementNilValueError.new(element: self) when "O", "C" then return "" else raise Eddy::Errors::Error, "Invalid req value: #{self.req}" end end return @val end # @param arg [String] # return [void] def value=(arg) if arg.nil? @val = arg return end raise Eddy::Errors::ElementValidationError.new("Value not present in code list: #{arg}", element: self) unless self.code_list().include?(arg) @val = arg end # @return [Array<String>] def code_list() raise NotImplementedError, "Each ID element must define its own code_list" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eddy-0.6.0 | lib/eddy/models/element/id.rb |