Sha256: a1c5683fecba22336618b23d01a172fc079835f1460a5fea93f4d549f06657d2

Contents?: true

Size: 827 Bytes

Versions: 3

Compression:

Stored size: 827 Bytes

Contents

module LinkedIn
  module Industry
    def self.all
      LinkedIn::API::Industries::INDUSTRIES
    end

    def self.[](code)
      find_by_code(code)
    end

    def self.find_by_code(code)
      all.detect { |indust| indust[:code] == code }
    end

    def self.find_by_group(*groups)
      all.reject { |indust| (groups & indust[:group]) != groups }
    end

    def self.find_by_description(description)
      all.detect { |indust| normalize_description(indust[:description]) == normalize_description(description) }
    end

    def self.find_group_names(*groups)
      Array[groups].flatten.map { |group| LinkedIn::API::Industries::GROUPS[group.to_sym] }
    end

    private

    def self.normalize_description(description)
      description.to_s.downcase.strip.gsub(' ','_').gsub(/[^\w]/, '').to_sym
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
linkedin2-0.0.16 lib/linkedin/industry.rb
linkedin2-0.0.15 lib/linkedin/industry.rb
linkedin2-0.0.14 lib/linkedin/industry.rb