Class: PolishNames
- Inherits:
-
Object
- Object
- PolishNames
- Defined in:
- lib/polish-flexive-name-endings/polish-flexive-name-endings.rb
Constant Summary collapse
- CSV_FILENAME =
'lib.csv'
- CSV_SEPARATOR =
';'
Class Method Summary collapse
Class Method Details
.load_data ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/polish-flexive-name-endings/polish-flexive-name-endings.rb', line 9 def load_data if @data.nil? @data = {} CSV.foreach(File.("../#{CSV_FILENAME}", __FILE__), headers: true, col_sep: CSV_SEPARATOR) do |csv_obj| @data[csv_obj['imie'].downcase] = { flexive: csv_obj['odmiana'], gender: csv_obj['plec'] == "M" ? :male : (csv_obj['plec'] == "K" ? :female : :unknown ), sylable: (csv_obj['sylaby'].to_i rescue 0) } end end end |
.parse_name(name) ⇒ Object
22 23 24 25 |
# File 'lib/polish-flexive-name-endings/polish-flexive-name-endings.rb', line 22 def parse_name(name) load_data @data[name.to_s.downcase] end |