Class: Saphyr::Fields::IsoLangField

Inherits:
FieldBase
  • Object
show all
Defined in:
lib/saphyr/fields/iso_lang_field.rb

Overview

The IsoLang field type (ISO-639-1/2).

Allowed options is: :version with possible values: 1 or 2

  • 1 : Mean ISO-639-1 (default)

  • 2 : Mean ISO-639-2

Constant Summary collapse

PREFIX =
'iso-lang'
EXPECTED_TYPES =
String
AUTHORIZED_OPTIONS =
[:version]
VERSION_1 =
[
  'aa', 'ab', 'ae', 'af', 'ak', 'am', 'an', 'ar', 'as', 'av', 'ay', 'az',
  'ba', 'be', 'bg', 'bh', 'bi', 'bm', 'bn', 'bo', 'br', 'bs', 'ca', 'ce',
  'ch', 'co', 'cr', 'cs', 'cu', 'cv', 'cy', 'da', 'de', 'dv', 'dz', 'ee',
  'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'ff', 'fi', 'fj', 'fo', 'fr',
  'fy', 'ga', 'gd', 'gl', 'gn', 'gu', 'gv', 'ha', 'he', 'hi', 'ho', 'hr',
  'ht', 'hu', 'hy', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'ik', 'io', 'is',
  'it', 'iu', 'ja', 'jv', 'ka', 'kg', 'ki', 'kj', 'kk', 'kl', 'km', 'kn',
  'ko', 'kr', 'ks', 'ku', 'kv', 'kw', 'ky', 'la', 'lb', 'lg', 'li', 'ln',
  'lo', 'lt', 'lu', 'lv', 'mg', 'mh', 'mi', 'mk', 'ml', 'mn', 'mr', 'ms',
  'mt', 'my', 'na', 'nb', 'nd', 'ne', 'ng', 'nl', 'nn', 'no', 'nr', 'nv',
  'ny', 'oc', 'oj', 'om', 'or', 'os', 'pa', 'pi', 'pl', 'ps', 'pt', 'qu',
  'rm', 'rn', 'ro', 'ru', 'rw', 'sa', 'sc', 'sd', 'se', 'sg', 'si', 'sk',
  'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'ss', 'st', 'su', 'sv', 'sw', 'ta',
  'te', 'tg', 'th', 'ti', 'tk', 'tl', 'tn', 'to', 'tr', 'ts', 'tt', 'tw',
  'ty', 'ug', 'uk', 'ur', 'uz', 've', 'vi', 'vo', 'wa', 'wo', 'xh', 'yi',
  'yo', 'za', 'zh', 'zu'
]
VERSION_2 =
[
  'aar', 'abk', 'ace', 'ach', 'ada', 'ady', 'afa', 'afh', 'afr', 'ain', 'aka',
  'akk', 'alb', 'ale', 'alg', 'alt', 'amh', 'ang', 'anp', 'apa', 'ara', 'arc',
  'arg', 'arm', 'arn', 'arp', 'art', 'arw', 'asm', 'ast', 'ath', 'aus', 'ava',
  'ave', 'awa', 'aym', 'aze', 'bad', 'bai', 'bak', 'bal', 'bam', 'ban', 'baq',
  'bas', 'bat', 'bej', 'bel', 'bem', 'ben', 'ber', 'bho', 'bih', 'bik', 'bin',
  'bis', 'bla', 'bnt', 'bos', 'bra', 'bre', 'btk', 'bua', 'bug', 'bul', 'bur',
  'byn', 'cad', 'cai', 'car', 'cat', 'cau', 'ceb', 'cel', 'cha', 'chb', 'che',
  'chg', 'chi', 'chk', 'chm', 'chn', 'cho', 'chp', 'chr', 'chu', 'chv', 'chy',
  'cmc', 'cnr', 'cop', 'cor', 'cos', 'cpe', 'cpf', 'cpp', 'cre', 'crh', 'crp',
  'csb', 'cus', 'cze', 'dak', 'dan', 'dar', 'day', 'del', 'den', 'dgr', 'din',
  'div', 'doi', 'dra', 'dsb', 'dua', 'dum', 'dut', 'dyu', 'dzo', 'efi', 'egy',
  'eka', 'elx', 'eng', 'enm', 'epo', 'est', 'ewe', 'ewo', 'fan', 'fao', 'fat',
  'fij', 'fil', 'fin', 'fiu', 'fon', 'fre', 'frm', 'fro', 'frr', 'frs', 'fry',
  'ful', 'fur', 'gaa', 'gay', 'gba', 'gem', 'geo', 'ger', 'gez', 'gil', 'gla',
  'gle', 'glg', 'glv', 'gmh', 'goh', 'gon', 'gor', 'got', 'grb', 'grc', 'gre',
  'grn', 'gsw', 'guj', 'gwi', 'hai', 'hat', 'hau', 'haw', 'heb', 'her', 'hil',
  'him', 'hin', 'hit', 'hmn', 'hmo', 'hrv', 'hsb', 'hun', 'hup', 'iba', 'ibo',
  'ice', 'ido', 'iii', 'ijo', 'iku', 'ile', 'ilo', 'ina', 'inc', 'ind', 'ine',
  'inh', 'ipk', 'ira', 'iro', 'ita', 'jav', 'jbo', 'jpn', 'jpr', 'jrb', 'kaa',
  'kab', 'kac', 'kal', 'kam', 'kan', 'kar', 'kas', 'kau', 'kaw', 'kaz', 'kbd',
  'kha', 'khi', 'khm', 'kho', 'kik', 'kin', 'kir', 'kmb', 'kok', 'kom', 'kon',
  'kor', 'kos', 'kpe', 'krc', 'krl', 'kro', 'kru', 'kua', 'kum', 'kur', 'kut',
  'lad', 'lah', 'lam', 'lao', 'lat', 'lav', 'lez', 'lim', 'lin', 'lit', 'lol',
  'loz', 'ltz', 'lua', 'lub', 'lug', 'lui', 'lun', 'luo', 'lus', 'mac', 'mad',
  'mag', 'mah', 'mai', 'mak', 'mal', 'man', 'mao', 'map', 'mar', 'mas', 'may',
  'mdf', 'mdr', 'men', 'mga', 'mic', 'min', 'mis', 'mkh', 'mlg', 'mlt', 'mnc',
  'mni', 'mno', 'moh', 'mon', 'mos', 'mul', 'mun', 'mus', 'mwl', 'mwr', 'myn',
  'myv', 'nah', 'nai', 'nap', 'nau', 'nav', 'nbl', 'nde', 'ndo', 'nds', 'nep',
  'new', 'nia', 'nic', 'niu', 'nno', 'nob', 'nog', 'non', 'nor', 'nqo', 'nso',
  'nub', 'nwc', 'nya', 'nym', 'nyn', 'nyo', 'nzi', 'oci', 'oji', 'ori', 'orm',
  'osa', 'oss', 'ota', 'oto', 'paa', 'pag', 'pal', 'pam', 'pan', 'pap', 'pau',
  'peo', 'per', 'phi', 'phn', 'pli', 'pol', 'pon', 'por', 'pra', 'pro', 'pus',
  'qaa', 'que', 'raj', 'rap', 'rar', 'roa', 'roh', 'rom', 'rum', 'run', 'rup',
  'rus', 'sad', 'sag', 'sah', 'sai', 'sal', 'sam', 'san', 'sas', 'sat', 'scn',
  'sco', 'sel', 'sem', 'sga', 'sgn', 'shn', 'sid', 'sin', 'sio', 'sit', 'sla',
  'slo', 'slv', 'sma', 'sme', 'smi', 'smj', 'smn', 'smo', 'sms', 'sna', 'snd',
  'snk', 'sog', 'som', 'son', 'sot', 'spa', 'srd', 'srn', 'srp', 'srr', 'ssa',
  'ssw', 'suk', 'sun', 'sus', 'sux', 'swa', 'swe', 'syc', 'syr', 'tah', 'tai',
  'tam', 'tat', 'tel', 'tem', 'ter', 'tet', 'tgk', 'tgl', 'tha', 'tib', 'tig',
  'tir', 'tiv', 'tkl', 'tlh', 'tli', 'tmh', 'tog', 'ton', 'tpi', 'tsi', 'tsn',
  'tso', 'tuk', 'tum', 'tup', 'tur', 'tut', 'tvl', 'twi', 'tyv', 'udm', 'uga',
  'uig', 'ukr', 'umb', 'und', 'urd', 'uzb', 'vai', 'ven', 'vie', 'vol', 'vot',
  'wak', 'wal', 'war', 'was', 'wel', 'wen', 'wln', 'wol', 'xal', 'xho', 'yao',
  'yap', 'yid', 'yor', 'ypk', 'zap', 'zbl', 'zen', 'zgh', 'zha', 'znd', 'zul',
  'zun', 'zxx', 'zza'
]

Constants inherited from FieldBase

FieldBase::DEFAULT_OPTS, FieldBase::DEFAULT_OPT_VALUES, FieldBase::EXCLUSIVE_OPTIONS, FieldBase::NOT_EQUALS_OPTIONS, FieldBase::NOT_SUP_OPTIONS, FieldBase::NOT_SUP_OR_EQUALS_OPTIONS, FieldBase::REQUIRED_ONE_OF_OPTIONS, FieldBase::REQUIRED_OPTIONS

Constants included from Asserts::ErrorConstants

Asserts::ErrorConstants::ERR_BAD_FORMAT, Asserts::ErrorConstants::ERR_EQ, Asserts::ErrorConstants::ERR_GT, Asserts::ErrorConstants::ERR_GTE, Asserts::ErrorConstants::ERR_IN, Asserts::ErrorConstants::ERR_LEN, Asserts::ErrorConstants::ERR_LT, Asserts::ErrorConstants::ERR_LTE, Asserts::ErrorConstants::ERR_MAX, Asserts::ErrorConstants::ERR_MIN, Asserts::ErrorConstants::ERR_NOT_EMPTY, Asserts::ErrorConstants::ERR_NOT_NULLABLE, Asserts::ErrorConstants::ERR_REGEXP, Asserts::ErrorConstants::ERR_SIZE_EQ, Asserts::ErrorConstants::ERR_SIZE_LEN, Asserts::ErrorConstants::ERR_SIZE_MAX, Asserts::ErrorConstants::ERR_SIZE_MIN, Asserts::ErrorConstants::ERR_TYPE

Instance Attribute Summary

Attributes inherited from FieldBase

#opts

Instance Method Summary collapse

Methods inherited from FieldBase

#authorized_options, #default?, #err, #exclusive_options, #expected_types, #not_equals_options, #not_sup_options, #not_sup_or_equals_options, #nullable?, #prefix, #required?, #required_one_of_options, #required_options, #validate

Methods included from Asserts::StringAssert

#assert_string_regexp

Methods included from Asserts::NumericAssert

#assert_numeric_gt, #assert_numeric_gte, #assert_numeric_lt, #assert_numeric_lte

Methods included from Asserts::SizeAssert

#assert_size_len, #assert_size_max, #assert_size_min

Methods included from Asserts::BaseAssert

#assert_boolean, #assert_class, #assert_eq, #assert_in, #assert_not_empty

Constructor Details

#initialize(opts = {}) ⇒ IsoLangField

Returns a new instance of IsoLangField.



82
83
84
85
86
87
88
89
90
91
# File 'lib/saphyr/fields/iso_lang_field.rb', line 82

def initialize(opts={})
  if opts[:version].nil?
    opts[:version] = 1
  else
    if opts[:version] != 1 and opts[:version] != 2
      raise Saphyr::Error.new 'Bad language akpha option must be : 2 or 3'
    end
  end
  super opts
end