Class: Worldwide::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/worldwide/field.rb

Constant Summary collapse

VALID_KEYS =
[
  :first_name,
  :last_name,
  :company,
  :address1,
  :address2,
  :city,
  :province,
  :zip,
  :country,
  :phone,
  :address,
]

Instance Method Summary collapse

Constructor Details

#initialize(country_code:, field_key:) ⇒ Field

Returns a new instance of Field.



23
24
25
26
# File 'lib/worldwide/field.rb', line 23

def initialize(country_code:, field_key:)
  @country_code = country_code.upcase.to_sym
  @field_key = field_key.downcase.to_sym
end

Instance Method Details

#autofill(locale: I18n.locale) ⇒ Object



28
29
30
# File 'lib/worldwide/field.rb', line 28

def autofill(locale: I18n.locale)
  lookup("autofill", locale: locale)
end

#error(locale: I18n.locale, code:, options: {}) ⇒ Object



40
41
42
# File 'lib/worldwide/field.rb', line 40

def error(locale: I18n.locale, code:, options: {})
  lookup("errors.#{code}", locale: locale, options: options)
end

#label(locale: I18n.locale) ⇒ Object



32
33
34
# File 'lib/worldwide/field.rb', line 32

def label(locale: I18n.locale)
  lookup("label.default", locale: locale)
end

#label_marked_optional(locale: I18n.locale) ⇒ Object



36
37
38
# File 'lib/worldwide/field.rb', line 36

def label_marked_optional(locale: I18n.locale)
  lookup("label.optional", locale: locale)
end

#warning(locale: I18n.locale, code:, options: {}) ⇒ Object



44
45
46
# File 'lib/worldwide/field.rb', line 44

def warning(locale: I18n.locale, code:, options: {})
  lookup("warnings.#{code}", locale: locale, options: options)
end