Sha256: 6eb5c49cdc088ae72d467fca8aae0f4929c505b2f1a45ebe14e0f078797f9626
Contents?: true
Size: 741 Bytes
Versions: 4
Compression:
Stored size: 741 Bytes
Contents
module Isic class Search FILES = { en: 'files/ISIC_Rev_4_english_structure.txt', es: 'files/ISIC_Rev_4_spanish_structure.txt', fr: 'files/ISIC_Rev_4_french_structure.txt' } ENCODINGS = { en: 'utf-8', es: 'iso-8859-15:utf-8', fr: 'iso-8859-15:utf-8' } def initialize(regexp, translation: :en) @regexp = regexp @file = FILES[translation] @encoding = ENCODINGS[translation] end def all entities = [] File.open(@file, encoding: @encoding).each do |line| md = /"(#{@regexp})","(.+)"/.match(line) entities << {code: md[1], description: md[2]} if md end entities end def first all.first end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
isic-1.0.2 | lib/isic/search.rb |
isic-1.0.1 | lib/isic/search.rb |
isic-1.0.0 | lib/isic/search.rb |
isic-0.9.0 | lib/isic/search.rb |