Class: Eddy::Elements::E116

Inherits:
Models::Element::AN show all
Defined in:
lib/definitions/elements/manual/116.postal_code.rb

Overview

Element Summary:

  • Id: 116
  • Name: Postal Code
  • Type: ID
  • Min/Max: 3/15
  • Description: Code defining international postal zone code excluding punctuation and blanks (zip code for United States)

Notes:

Instance Attribute Summary

Attributes inherited from Models::Element::Base

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

Instance Method Summary collapse

Methods inherited from Models::Element::AN

#process_value, process_value, #value, #value=

Methods inherited from Models::Element::Base

#doc_comment, #process_value, process_value, #req, #req=, #value, #value=

Constructor Details

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

Parameters:

  • val (String) (defaults to: nil)

    (nil)

  • req (String) (defaults to: nil)

    (nil)

  • ref (String) (defaults to: nil)

    (nil)



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/definitions/elements/manual/116.postal_code.rb', line 22

def initialize(val: nil, req: nil, ref: nil)
  @id = "116"
  @name = "Postal Code"
  @description = "Code defining international postal zone code excluding punctuation and blanks (zip code for United States)"
  super(
    min: 3,
    max: 15,
    req: req,
    ref: ref,
    val: val,
  )
end

Instance Method Details

#patternRegexp

Matches any valid US zip code.

Returns:

  • (Regexp)


38
39
40
# File 'lib/definitions/elements/manual/116.postal_code.rb', line 38

def pattern
  return /^[0-9]{5}(?:-[0-9]{4})?$/
end