class UncleKryon::BaseIso

Attributes

code[R]
name[R]

Public Class Methods

fix_name(name) click to toggle source
# File lib/unclekryon/iso/base_iso.rb, line 31
def self.fix_name(name)
  return flip_word_order(simplify_name(name))
end
flip_word_order(word) click to toggle source
# File lib/unclekryon/iso/base_iso.rb, line 35
def self.flip_word_order(word)
  # e.g., change 'English, Old' to 'Old English'
  return word.gsub(/([^\,\;]+)[[:space:]]*[\,\;]+[[:space:]]*([^\,\;]+)/,'\\2 \\1').strip
end
new() click to toggle source
Calls superclass method UncleKryon::BaseData::new
# File lib/unclekryon/iso/base_iso.rb, line 24
def initialize
  super()

  @name = nil
  @code = nil
end
simplify_code(code) click to toggle source
# File lib/unclekryon/iso/base_iso.rb, line 40
def self.simplify_code(code)
  # e.g., remove 'US-' from 'US-AL'
  return code.gsub(/[[:alnum:][:space:]]+\-[[:space:]]*/,'').strip
end
simplify_name(name) click to toggle source
# File lib/unclekryon/iso/base_iso.rb, line 45
def self.simplify_name(name)
  # e.g., remove '(the)' from 'United States of America (the)'
  return name.gsub(/[[:space:]]*\([^\)]*\)[[:space:]]*/,'').strip
end

Public Instance Methods

==(other) click to toggle source
# File lib/unclekryon/iso/base_iso.rb, line 50
def ==(other)
  return @name == other.name && @code == other.code
end
to_s() click to toggle source
# File lib/unclekryon/iso/base_iso.rb, line 54
def to_s
  return %Q(["#{@name}",#{@code}])
end