Class: LLT::AdjectiveBuilder

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

Direct Known Subclasses

AdverbBuilder

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, #compute, #endings_lookup, #extended_special_forms, #index_of_ending, #indices, #initialize, #irregulars_with_nominative, #new_attributes, #new_form_through_index, #new_special_form, #o_declension_on_ius?, #proper_vocative, #regular_forms, #special_ending, #with_replacements

Methods inherited from FormBuilder

#attributes_by_index, build, #compute, #cross_indices, #default_args, #downcase_all_stems, #endings, #endings_attributes, #endings_container, #endings_lookup, #endings_namespace, #endings_path, #extensions_and_other_signs, #form_class, #indices_by_ending, #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

#comp_sign(c, s, n) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/llt/form_builder/adjective_builder.rb', line 65

def comp_sign(c, s, n)
  if s == :n && n == 1 && c.to_s.match(/^(1|4|5)$/)
    marker(:COMP_N)
  else
    marker(:COMP_MF)
  end
end

#comparativus_extraction(stem, args) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/llt/form_builder/adjective_builder.rb', line 55

def comparativus_extraction(stem, args)
  c = args[:casus]
  s = args[:sexus]
  n = args[:numerus]

  new_stem = stem.chomp(marker(:COMP_MF)) # do not use chomp! as other forms will get severed
  raise "No comparison sign for comparative present" if new_stem == stem
  [new_stem, comp_sign(c, s, n)]
end

#corrections(args) ⇒ Object



33
34
35
# File 'lib/llt/form_builder/adjective_builder.rb', line 33

def corrections(args)
  extract_comparison_sign(args)
end

#er_nominative_possible?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/llt/form_builder/adjective_builder.rb', line 82

def er_nominative_possible?
  @inflection_class == 1
end

#extract_comparison_sign(args) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/llt/form_builder/adjective_builder.rb', line 37

def extract_comparison_sign(args)
  return if @comparatio == :positivus

  st = args[:stem]

  case @comparatio
  when :comparativus
    new_stem, new_comp_sign = comparativus_extraction(st, args)
  when :superlativus
    st.match(/(#{marker(:RIM)}|#{marker(:LIM)}|#{marker(:ISSIM)})$/)
    new_stem      = st.chomp($1)
    new_comp_sign = $1
  end

  args[:stem] = new_stem
  args[:comparison_sign] = new_comp_sign
end

#init_keysObject



10
11
12
# File 'lib/llt/form_builder/adjective_builder.rb', line 10

def init_keys
  super + %i{ comparatio number_of_endings }
end

#marker(const) ⇒ Object



78
79
80
# File 'lib/llt/form_builder/adjective_builder.rb', line 78

def marker(const)
  markers_path.const_get(const)
end

#markers_pathObject



73
74
75
76
# File 'lib/llt/form_builder/adjective_builder.rb', line 73

def markers_path
  path = constant_by_type(namespace: LLT::Constants::Markers)
  metrical? ? path::Metrical : path
end

#nominativesObject



14
15
16
17
18
19
20
# File 'lib/llt/form_builder/adjective_builder.rb', line 14

def nominatives
  res  = [[@nom, 1, 1]]
  if @number_of_endings == 1 && @inflection_class == 3
    res += [[@nom, 1, 1, :f], [@nom, 1, 1, :n]]
  end
  res
end

#pronominal_declension?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/llt/form_builder/adjective_builder.rb', line 22

def pronominal_declension?
  @inflection_class == 5 && @number_of_endings == 3
end

#regular_o_declension?Boolean

having this not implemented separately in the adjective builder led to problems with vocatives! The infl class for detecting O is different here!

Returns:

  • (Boolean)


29
30
31
# File 'lib/llt/form_builder/adjective_builder.rb', line 29

def regular_o_declension?
  @inflection_class == 1 && @nom.to_s =~ /us$/ # to_s because it might be nil
end