Class: LLT::PersonalPronounBuilder

Inherits:
DeclinableBuilder show all
Defined in:
lib/llt/form_builder/personal_pronoun_builder.rb

Constant Summary

Constants inherited from FormBuilder

FormBuilder::VERSION

Instance Attribute Summary

Attributes inherited from DeclinableBuilder

#comparatio, #sexus

Attributes inherited from FormBuilder

#impersonalium

Instance Method Summary collapse

Methods inherited from DeclinableBuilder

#additional_forms, #casus_numerus_sexus_by_index, #endings_lookup, #er_nominative_possible?, #extended_special_forms, #index_of_ending, #initialize, #irregulars_with_nominative, #new_attributes, #new_special_form, #o_declension_on_ius?, #pronominal_declension?, #proper_vocative, #regular_forms, #regular_o_declension?, #special_ending, #with_replacements

Methods inherited from FormBuilder

#attributes_by_index, build, #corrections, #cross_indices, #downcase_all_stems, #endings, #endings_attributes, #endings_container, #endings_lookup, #endings_namespace, #endings_path, #extensions_and_other_signs, #form_class, #indices_by_ending, #init_keys, #initialize, #keep_given_value, lookup_class, #lookup_indices, #needs_validation?, #new_form, #prefix, #reverse_lookup, #stays_capitalized, #stem_copy, #valid?, #validation_rule, #validations, validations, #value_as_index

Constructor Details

This class inherits a constructor from LLT::DeclinableBuilder

Instance Method Details

#additional_genetivesObject



37
38
39
40
41
42
43
# File 'lib/llt/form_builder/personal_pronoun_builder.rb', line 37

def additional_genetives
  if nos_or_vos && @lookup_indices.include?(7) # gen.pl
    [new_form_through_index("#{@inflection_class}trum", 7)]
  else
    []
  end
end

#computeObject



14
15
16
# File 'lib/llt/form_builder/personal_pronoun_builder.rb', line 14

def compute
  (regular_forms + forms_with_suffix + additional_genetives).sort_by(&:index)
end

#default_argsObject



56
57
58
59
# File 'lib/llt/form_builder/personal_pronoun_builder.rb', line 56

def default_args
  # need to override, because we want to use our custom "stem", which is actually the form itself
  { inflection_class: @inflection_class }
end

#formsObject



18
19
20
# File 'lib/llt/form_builder/personal_pronoun_builder.rb', line 18

def forms
  endings
end

#forms_with_suffixObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/llt/form_builder/personal_pronoun_builder.rb', line 22

def forms_with_suffix
  suffixeds = SUFFIXED_FORMS[@inflection_class]
  res = []
  return res unless suffixeds
  suffixeds.each do |i, suffixes|
    if @lookup_indices.include?(i)
      suffixes.each do |suffix|
        f = forms[i]
        res << new_form_through_index(f, i, suffix)
      end
    end
  end
  res.flatten.compact
end

#indicesObject



7
8
9
10
11
12
# File 'lib/llt/form_builder/personal_pronoun_builder.rb', line 7

def indices
  {
    casus: [0, 1, 2, 3, nil, 5],
    numerus: [0, 6],
  }
end

#new_form_through_index(form, i, suffix = "") ⇒ Object



49
50
51
52
53
54
# File 'lib/llt/form_builder/personal_pronoun_builder.rb', line 49

def new_form_through_index(form, i, suffix = "")
  # nil values in ending == form present, vocatives f.e., or se in nom.
  return unless form
  c, n = casus_numerus_sexus_by_index(i)
  new_form(stem: form, casus: c, numerus: n, suffix: suffix, index: i)
end

#nos_or_vosObject



45
46
47
# File 'lib/llt/form_builder/personal_pronoun_builder.rb', line 45

def nos_or_vos
  @inflection_class == :nos || @inflection_class == :vos
end