Class: Fias::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/fias/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Config

Returns a new instance of Config.

Yields:

  • (_self)

Yield Parameters:

  • _self (Fias::Config)

    the object that the method was called on



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

#aliasesObject (readonly)

Returns the value of attribute aliases.



19
20
21
# File 'lib/fias/config.rb', line 19

def aliases
  @aliases
end

#exceptionsObject (readonly)

Returns the value of attribute exceptions.



19
20
21
# File 'lib/fias/config.rb', line 19

def exceptions
  @exceptions
end

#indexObject (readonly)

Returns the value of attribute index.



19
20
21
# File 'lib/fias/config.rb', line 19

def index
  @index
end

#longsObject (readonly)

Returns the value of attribute longs.



19
20
21
# File 'lib/fias/config.rb', line 19

def longs
  @longs
end

#proper_namesObject (readonly)

Returns the value of attribute proper_names.



20
21
22
# File 'lib/fias/config.rb', line 20

def proper_names
  @proper_names
end

#replacementsObject (readonly)

Returns the value of attribute replacements.



19
20
21
# File 'lib/fias/config.rb', line 19

def replacements
  @replacements
end

#shortsObject (readonly)

Returns the value of attribute shorts.



19
20
21
# File 'lib/fias/config.rb', line 19

def shorts
  @shorts
end

#synonymsObject (readonly)

Returns the value of attribute synonyms.



20
21
22
# File 'lib/fias/config.rb', line 20

def synonyms
  @synonyms
end

#synonyms_indexObject (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