Module: Utilities::Latin
- Defined in:
- lib/utilities/latin.rb
Constant Summary collapse
- ENDINGS =
rubocop:disable Style/StringHashKeys
{ '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} }.freeze
Class Method Summary collapse
-
.all_endings ⇒ Array
An Array of all endings sorted by length, longest first.
- .root(name) ⇒ Boolean
- .same_root_name?(name1, name2) ⇒ Boolean
Class Method Details
.all_endings ⇒ Array
An Array of all endings sorted by length, longest first
24 25 26 |
# File 'lib/utilities/latin.rb', line 24 def self.all_endings (ENDINGS.keys + ENDINGS.values).flatten.sort{|a,b| b.length <=> a.length} end |
.root(name) ⇒ Boolean
30 31 32 33 34 35 36 37 38 |
# File 'lib/utilities/latin.rb', line 30 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 |
.same_root_name?(name1, name2) ⇒ Boolean
18 19 20 |
# File 'lib/utilities/latin.rb', line 18 def self.same_root_name?(name1, name2) return false if (name1.length - name2.length).abs > 1 end |