class Arbetsformedlingen::Company

Public Class Methods

new(hash) click to toggle source
Calls superclass method
# File lib/arbetsformedlingen/models/company.rb, line 27
def initialize(hash)
  super(CompanySchema.call(hash))
end

Public Instance Methods

cin_arbetsformedlingen(cin) click to toggle source

Formats a Company Identification Number the way Arbetsformedlingen likes it

# File lib/arbetsformedlingen/models/company.rb, line 44
def cin_arbetsformedlingen(cin)
  String.new(cin.dup).
    delete('-').
    insert(6, '-').
    insert(0, '46-')
end
to_h() click to toggle source
Calls superclass method
# File lib/arbetsformedlingen/models/company.rb, line 31
def to_h
  hash = super
  address = hash.fetch(:address)
  hash[:address][:full_address] = [
    address.fetch(:street),
    address.fetch(:zip),
    address.fetch(:city),
  ].join(', ')
  hash[:cin_arbetsformedlingen] = cin_arbetsformedlingen(hash.fetch(:cin))
  hash
end