Method: Eddy::Models::Element::TM#initialize

Defined in:
lib/eddy/models/element/tm.rb

#initialize(min: nil, max: nil, req: nil, ref: nil, val: nil, fmt: nil) ⇒ void

TM elements require either a fmt value, or min and max values.

Parameters:

  • min (Integer) (defaults to: nil)

    (nil)

  • max (Integer) (defaults to: nil)

    (nil)

  • req (String) (defaults to: nil)

    (nil)

  • ref (String) (defaults to: nil)

    (nil)

  • val (Time) (defaults to: nil)

    (nil)

  • fmt (Symbol) (defaults to: nil)

    (nil) Format for the date. Valid values: :hhmm, :hhmmss, :hhmmssd, and :hhmmssdd

Raises:

  • (ArgumentError)

    If an invalid format argument is passed.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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