Module: Latin

Defined in:
lib/latin.rb

Constant Summary

ENDINGS =
{
  'er' => %w{ra era rum},
  'or' => %w{rix}, 
  'ae' => %w{ei a e i},
  'anum' => %w{ensis},
  'major' => %w{majus},
  's' => %w{es is us},
  'm' => %w{um}
}

Class Method Summary (collapse)

Class Method Details

+ (Object) all_endings

An Array of all endings sorted by length, longest first



18
19
20
# File 'lib/latin.rb', line 18

def self.all_endings
  (ENDINGS.keys + ENDINGS.values).flatten.sort{|a,b| b.length <=> a.length}
end

+ (Object) root(name)



22
23
24
25
26
27
28
29
30
# File 'lib/latin.rb', line 22

def self.root(name)
  return false if name.nil? || name.class != String
  self.all_endings.each do |e|
    if name =~ /(?<s>.*)#{e}\Z/ 
      return $~[:s] 
    end
  end
  false
end

+ (Boolean) same_root_name?(name1, name2)

Returns:

  • (Boolean)


13
14
15
# File 'lib/latin.rb', line 13

def self.same_root_name?(name1, name2)
  return false if (name1.length - name2.length).abs > 1
end