Class: Fias::Config
- Inherits:
-
Object
- Object
- Fias::Config
- Defined in:
- lib/fias/config.rb
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
-
#exceptions ⇒ Object
readonly
Returns the value of attribute exceptions.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#longs ⇒ Object
readonly
Returns the value of attribute longs.
-
#proper_names ⇒ Object
readonly
Returns the value of attribute proper_names.
-
#replacements ⇒ Object
readonly
Returns the value of attribute replacements.
-
#shorts ⇒ Object
readonly
Returns the value of attribute shorts.
-
#synonyms ⇒ Object
readonly
Returns the value of attribute synonyms.
-
#synonyms_index ⇒ Object
readonly
Returns the value of attribute synonyms_index.
Instance Method Summary collapse
- #add_exception(long, short) ⇒ Object
- #add_name(long, short, aliases = []) ⇒ Object
- #add_proper_name(name) ⇒ Object
- #add_replacement(target, value) ⇒ Object
- #add_synonym(*names) ⇒ Object
-
#initialize {|_self| ... } ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize {|_self| ... } ⇒ Config
Returns a new instance of Config.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fias/config.rb', line 3 def initialize @index = {} @longs = {} @shorts = {} @aliases = {} @exceptions = {} @proper_names = [] @replacements = {} @synonyms = [] @synonyms_index = {} yield(self) finalize_index end |
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
19 20 21 |
# File 'lib/fias/config.rb', line 19 def aliases @aliases end |
#exceptions ⇒ Object (readonly)
Returns the value of attribute exceptions.
19 20 21 |
# File 'lib/fias/config.rb', line 19 def exceptions @exceptions end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
19 20 21 |
# File 'lib/fias/config.rb', line 19 def index @index end |
#longs ⇒ Object (readonly)
Returns the value of attribute longs.
19 20 21 |
# File 'lib/fias/config.rb', line 19 def longs @longs end |
#proper_names ⇒ Object (readonly)
Returns the value of attribute proper_names.
20 21 22 |
# File 'lib/fias/config.rb', line 20 def proper_names @proper_names end |
#replacements ⇒ Object (readonly)
Returns the value of attribute replacements.
19 20 21 |
# File 'lib/fias/config.rb', line 19 def replacements @replacements end |
#shorts ⇒ Object (readonly)
Returns the value of attribute shorts.
19 20 21 |
# File 'lib/fias/config.rb', line 19 def shorts @shorts end |
#synonyms ⇒ Object (readonly)
Returns the value of attribute synonyms.
20 21 22 |
# File 'lib/fias/config.rb', line 20 def synonyms @synonyms end |
#synonyms_index ⇒ Object (readonly)
Returns the value of attribute synonyms_index.
20 21 22 |
# File 'lib/fias/config.rb', line 20 def synonyms_index @synonyms_index end |
Instance Method Details
#add_exception(long, short) ⇒ Object
34 35 36 37 |
# File 'lib/fias/config.rb', line 34 def add_exception(long, short) @exceptions[Unicode.downcase(short)] = [long, short] @exceptions[Unicode.downcase(long)] = [long, short] end |
#add_name(long, short, aliases = []) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/fias/config.rb', line 22 def add_name(long, short, aliases = []) @longs[Unicode.downcase(short)] = long @shorts[Unicode.downcase(long)] = short @aliases[Unicode.downcase(long)] = aliases populate_index(long, short, aliases) end |
#add_proper_name(name) ⇒ Object
39 40 41 |
# File 'lib/fias/config.rb', line 39 def add_proper_name(name) @proper_names << name end |
#add_replacement(target, value) ⇒ Object
30 31 32 |
# File 'lib/fias/config.rb', line 30 def add_replacement(target, value) @replacements[Unicode.downcase(target)] = value end |
#add_synonym(*names) ⇒ Object
43 44 45 46 |
# File 'lib/fias/config.rb', line 43 def add_synonym(*names) @synonyms << names populate_synonyms_index(names) end |