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
# File 'lib/fias/config.rb', line 3

def initialize
  @index = {}
  @longs = {}
  @shorts = {}
  @aliases = {}
  @exceptions = {}
  @proper_names = []
  @synonyms = []
  @synonyms_index = {}

  yield(self)

  finalize_index
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



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

def aliases
  @aliases
end

#exceptionsObject (readonly)

Returns the value of attribute exceptions.



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

def exceptions
  @exceptions
end

#indexObject (readonly)

Returns the value of attribute index.



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

def index
  @index
end

#longsObject (readonly)

Returns the value of attribute longs.



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

def longs
  @longs
end

#proper_namesObject (readonly)

Returns the value of attribute proper_names.



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

def proper_names
  @proper_names
end

#shortsObject (readonly)

Returns the value of attribute shorts.



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

def shorts
  @shorts
end

#synonymsObject (readonly)

Returns the value of attribute synonyms.



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

def synonyms
  @synonyms
end

#synonyms_indexObject (readonly)

Returns the value of attribute synonyms_index.



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

def synonyms_index
  @synonyms_index
end

Instance Method Details

#add_exception(long, short) ⇒ Object



29
30
31
32
# File 'lib/fias/config.rb', line 29

def add_exception(long, short)
  @exceptions[Unicode.downcase(short)] = [long, short]
  @exceptions[Unicode.downcase(long)] = [long, short]
end

#add_name(long, short, aliases = []) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/fias/config.rb', line 21

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



34
35
36
# File 'lib/fias/config.rb', line 34

def add_proper_name(name)
  @proper_names << name
end

#add_synonym(*names) ⇒ Object



38
39
40
41
# File 'lib/fias/config.rb', line 38

def add_synonym(*names)
  @synonyms << names
  populate_synonyms_index(names)
end