Class: Mic::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/mic/search.rb

Instance Method Summary collapse

Constructor Details

#initializeSearch

Returns a new instance of Search.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mic/search.rb', line 5

def initialize
  @a = []
  CSV.foreach(file) do |row|
    h = {}
    h[:mic] = row[2]
    h[:acronym] = row[6]
    h[:market_name] = row[5]
    h[:market_type] = row[4]
    h[:operating_mic] = row[3]
    h[:country_code] = row[1]
    h[:country_name] = row[0]
    h[:city] = row[7]
    h[:website] = row[8]
    @a << h
  end
end

Instance Method Details

#fileObject



27
28
29
# File 'lib/mic/search.rb', line 27

def file
  File.expand_path('../../files/ISO10383.csv', File.dirname(__FILE__))
end

#select_by(symbol, string, include_segments) ⇒ Object



22
23
24
25
# File 'lib/mic/search.rb', line 22

def select_by(symbol, string, include_segments)
  @a = @a.select{ |m| m[:market_type] == 'O' } unless include_segments
  @a.select{ |m| m[symbol] =~ Regexp.new(string, 'i') }
end