Sha256: 4817cda0825d7f81b6b1b88d26d10def8564f6255ff70a2754f4b46f2e84ca87
Contents?: true
Size: 843 Bytes
Versions: 2
Compression:
Stored size: 843 Bytes
Contents
class Isic class Entity def initialize(code) @code = code end def classify(options = {}) translation = options[:translation] || :en all_codes.inject({}) do |hash, (key, value)| hash[key] = Isic::Search.new(value, translation: translation).first hash end end private def all_codes case @code when /\d{4}/ {class: @code, group: @code[0..2], division: @code[0..1], section: section(@code[0..1])} when /\d{3}/ {group: @code, division: @code[0..1], section: section(@code[0..1])} when /\d{2}/ {division: @code, section: section(@code)} when /[A-Z]/ {section: @code} end end def section(division) Isic::DIVISIONS.select { |k,v| v.include?(division) }.keys.first end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
isic-1.0.5 | lib/isic/entity.rb |
isic-1.0.3 | lib/isic/entity.rb |