Module: Iso639Data

Defined in:
lib/iso-639-data.rb,
lib/iso-639-data/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

ISO_639_2 =
lambda do
  YAML.load(File.read(File.join(File.dirname(__FILE__), '2.yaml'))).tap do |h|
    h.each do |k,v|
      v.freeze
    end
  end
end.call.freeze
ISO_639_3 =
lambda do
  YAML.load(File.read(File.join(File.dirname(__FILE__), '3.yaml'))).tap do |h|
    h.each do |k,v|
      v.freeze
    end
  end
end.call.freeze
VERSION =
"0.1.4"

Class Method Summary collapse

Class Method Details

.codesObject



24
25
26
# File 'lib/iso-639-data.rb', line 24

def codes
  (ISO_639_2.keys << ISO_639_3.keys).flatten.uniq
end

.iso_639_2Object



32
33
34
# File 'lib/iso-639-data.rb', line 32

def iso_639_2
  ISO_639_2
end

.iso_639_3Object



36
37
38
# File 'lib/iso-639-data.rb', line 36

def iso_639_3
  ISO_639_3
end

.valid?(code) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/iso-639-data.rb', line 28

def valid?(code)
  codes.include? code
end