class Eddy::Models::Element::TM
Time in `HHMMSSDD` format. Time expressed in 24-hour clock time as follows: `HHMM`, or `HHMMSS`, or `HHMMSSD`, or `HHMMSSDD` where H = hours (00-23), M = minutes (00-59), S = integer seconds (00-59) and DD = decimal seconds; decimal seconds are expressed as follows: D = tenths (0-9) and DD = hundredths (00-99)
Values for this type are generated from a UTC formatted [Time] object.
[time]: ruby-doc.org/stdlib-2.6.5/libdoc/time/rdoc/Time.html
Attributes
Format for the date. Valid values: `:hhmm`, `:hhmmss`, `:hhmmssd`, and `:hhmmssdd` TODO: Decide if this should be an attr_accessor @return [Symbol<:hhmm, :hhmmss, :hhmmssd, :hhmmssdd>]
Public Class Methods
TM
elements require either a `fmt` value, or `min` and `max` values.
@raise [ArgumentError] If an invalid format argument is passed. @param min [Integer] (nil) @param max [Integer] (nil) @param req [String] (nil) @param ref [String] (nil) @param val [Time] (nil) @param fmt [Symbol] (nil) Format for the date. Valid values: `:hhmm`, `:hhmmss`, `:hhmmssd`, and `:hhmmssdd` @return [void]
# File lib/eddy/models/element/tm.rb, line 33 def initialize( min: nil, max: nil, req: nil, ref: nil, val: nil, fmt: nil ) @type = "TM" @min = min @max = max self.req = req self.ref = ref if fmt.nil? raise ArgumentError, "TM elements require either a `fmt` value, or `min` and `max` values." if min.nil? || max.nil? @fmt = determine_format() else self.fmt = fmt end self.value = val end
@param val [Time] A UTC formatted [Time](ruby-doc.org/stdlib-2.6.5/libdoc/time/rdoc/Time.html) object. @param fmt [Symbol] @return [String]
# File lib/eddy/models/element/tm.rb, line 86 def self.process_value(val, fmt) case fmt when :hhmm then return Eddy::Util::Time.hhmm(val) when :hhmmss then return Eddy::Util::Time.hhmmss(val) when :hhmmssd then return Eddy::Util::Time.hhmmssd(val) when :hhmmssdd then return Eddy::Util::Time.hhmmssdd(val) else raise Eddy::Errors::Error, "invalid fmt value for TM object" end end
Public Instance Methods
@return [Array<Symbol>]
# File lib/eddy/models/element/tm.rb, line 106 def accepted_formats() return [:hhmm, :hhmmss, :hhmmssd, :hhmmssdd] end
@return [Symbol]
# File lib/eddy/models/element/tm.rb, line 111 def determine_format() case self.max when 4 then return :hhmm when 6 then return :hhmmss when 7 then return :hhmmssd when 8 then return :hhmmssdd else raise Eddy::Errors::Error, "unable to determine format for TM element" end end
@param fmt [Symbol] @return [void]
# File lib/eddy/models/element/tm.rb, line 98 def fmt=(fmt) return if fmt.nil? fmt = fmt.to_sym.downcase raise ArgumentError unless accepted_formats.include?(fmt) @fmt = fmt end
@return [String]
# File lib/eddy/models/element/tm.rb, line 79 def process_value() return self.class.process_value(@val, self.fmt) end
@raise [Eddy::Errors::ElementNilValueError] If the element is required and no value has been set. @return [String]
Eddy::Models::Element::Base#value
# File lib/eddy/models/element/tm.rb, line 74 def value() return super() end
@raise [ElementValidationError] Unless passed a UTC formatted Time object. @param arg [Time] A UTC formatted `Time` object. @return [void]
# File lib/eddy/models/element/tm.rb, line 58 def value=(arg) if arg == :skip @val = :skip return end if arg.nil?() @val = arg return end raise Eddy::Errors::TypeValidationError.new(element: self, arg: arg) unless arg.is_a?(Time) raise Eddy::Errors::ElementValidationError.new("Argument is not in UTC format", element: self) unless arg.utc?() @val = arg end