class ISO::Subtag

Attributes

code[R]

Public Class Methods

all() click to toggle source
# File lib/iso/subtag.rb, line 24
def self.all
  @all ||= YAML.load_file(self::DEFINITIONS_FILE).map do |code, options|
    symbolized_options = {}
    options.keys.each { |key| symbolized_options[key.to_sym] = options[key] } if options
    new(code, symbolized_options)
  end
end
codes() click to toggle source
# File lib/iso/subtag.rb, line 40
def self.codes
  all.map(&:code)
end
default() click to toggle source
# File lib/iso/subtag.rb, line 36
def self.default
  find(self::DEFAULT_CODE)
end
find(code) click to toggle source
# File lib/iso/subtag.rb, line 32
def self.find(code)
  all.find {|subtag| subtag.code == code }
end
new(code, options={}) click to toggle source
# File lib/iso/subtag.rb, line 7
def initialize(code, options={})
  @code = code
  @options = options
end

Public Instance Methods

==(object) click to toggle source
# File lib/iso/subtag.rb, line 12
def ==(object)
  code == object.code
end
full_name() click to toggle source
# File lib/iso/subtag.rb, line 20
def full_name
  "#{code} - #{name}"
end
name() click to toggle source
# File lib/iso/subtag.rb, line 16
def name
  @options[:name] || I18n.t(code, :scope => i18n_scope)
end

Private Instance Methods

i18n_scope() click to toggle source
# File lib/iso/subtag.rb, line 45
def i18n_scope
  %w(vendor iso).join('.')
end