Class: Eddy::Models::Element::AN

Inherits:
Base
  • Object
show all
Defined in:
lib/eddy/models/element/an.rb

Overview

Alphanumeric string including special characters

Instance Attribute Summary

Attributes inherited from Base

#description, #id, #max, #min, #name, #ref, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#doc_comment, #req, #req=

Constructor Details

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

Parameters:

  • min (Integer)
  • max (Integer)
  • req (String) (defaults to: nil)

    (nil)

  • ref (String) (defaults to: nil)

    (nil)

  • val (String) (defaults to: nil)

    (nil)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/eddy/models/element/an.rb', line 13

def initialize(
  min:,
  max:,
  req: nil,
  ref: nil,
  val: nil
)
  @type = "AN"
  @min = min
  @max = max
  self.req = req
  self.ref = ref
  self.value = val
end

Class Method Details

.process_value(val, min, _max) ⇒ String

Left justify a string (val) to min.

Parameters:

  • val (String)

    Original value.

  • min (Integer)

    Minimum length for a valid value.

  • _max (Integer)

    Maximum length for a valid value.

Returns:

  • (String)


62
63
64
# File 'lib/eddy/models/element/an.rb', line 62

def self.process_value(val, min, _max)
  return val.ljust(min)
end

Instance Method Details

#process_valueString

Returns:

  • (String)


52
53
54
# File 'lib/eddy/models/element/an.rb', line 52

def process_value()
  return self.class.process_value(@val, self.min, self.max)
end

#valueString

Returns:

  • (String)

Raises:



47
48
49
# File 'lib/eddy/models/element/an.rb', line 47

def value()
  return super()
end

#value=(arg) ⇒ void

This method returns an undefined value.

Parameters:

  • arg (String)

Raises:



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/eddy/models/element/an.rb', line 31

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?(String)
  raise Eddy::Errors::LengthValidationError.new(element: self, arg: arg) if arg.length > self.max
  @val = arg
end