Class: Mic::Search
- Inherits:
-
Object
- Object
- Mic::Search
- Defined in:
- lib/mic/search.rb
Instance Method Summary collapse
- #file ⇒ Object
-
#initialize ⇒ Search
constructor
A new instance of Search.
- #select_by(symbol, string, include_segments) ⇒ Object
Constructor Details
#initialize ⇒ Search
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
#file ⇒ Object
27 28 29 |
# File 'lib/mic/search.rb', line 27 def file File.('../../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 |