Class: Israeli::PostalCodeResult

Inherits:
Result
  • Object
show all
Defined in:
lib/israeli/result.rb

Overview

Result object for postal code validation with formatting.

Instance Attribute Summary

Attributes inherited from Result

#normalized, #original, #reason

Instance Method Summary collapse

Methods inherited from Result

#initialize, #invalid?, #to_s, #valid?, #value

Constructor Details

This class inherits a constructor from Israeli::Result

Instance Method Details

#formatted(style: :compact) ⇒ String?

Format the postal code.

Parameters:

  • style (Symbol) (defaults to: :compact)

    :compact or :spaced

Returns:

  • (String, nil)

    Formatted postal code or nil if invalid



114
115
116
117
118
# File 'lib/israeli/result.rb', line 114

def formatted(style: :compact)
  return nil unless valid?

  Validators::PostalCode.format(@normalized, style: style)
end