Class: AtlasEngine::FieldDecompounder
- Inherits:
-
Object
- Object
- AtlasEngine::FieldDecompounder
- Extended by:
- T::Sig
- Defined in:
- app/models/atlas_engine/field_decompounder.rb
Instance Attribute Summary collapse
-
#country_profile ⇒ Object
readonly
Returns the value of attribute country_profile.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(field:, value:, country_profile:) ⇒ FieldDecompounder
constructor
A new instance of FieldDecompounder.
Constructor Details
#initialize(field:, value:, country_profile:) ⇒ FieldDecompounder
Returns a new instance of FieldDecompounder.
11 12 13 14 15 |
# File 'app/models/atlas_engine/field_decompounder.rb', line 11 def initialize(field:, value:, country_profile:) @field = field @value = value @country_profile = country_profile end |
Instance Attribute Details
#country_profile ⇒ Object (readonly)
Returns the value of attribute country_profile.
8 9 10 |
# File 'app/models/atlas_engine/field_decompounder.rb', line 8 def country_profile @country_profile end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
8 9 10 |
# File 'app/models/atlas_engine/field_decompounder.rb', line 8 def field @field end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'app/models/atlas_engine/field_decompounder.rb', line 8 def value @value end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/atlas_engine/field_decompounder.rb', line 18 def call country_profile.decompounding_patterns(field)&.each do |pattern| transliterated_street = ActiveSupport::Inflector.transliterate(value.to_s) if (match = transliterated_street.match((pattern))) return (match[:pre] + match[:name] + " " + match[:suffix] + match[:post]).strip end end value end |