Class: Arbetsformedlingen::Company
- Defined in:
- lib/arbetsformedlingen/models/company.rb
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
-
#cin_arbetsformedlingen(cin) ⇒ Object
Formats a Company Identification Number the way Arbetsformedlingen likes it.
-
#initialize(hash) ⇒ Company
constructor
A new instance of Company.
- #to_h ⇒ Object
Methods inherited from Model
Constructor Details
#initialize(hash) ⇒ Company
Returns a new instance of Company.
27 28 29 |
# File 'lib/arbetsformedlingen/models/company.rb', line 27 def initialize(hash) super(CompanySchema.call(hash)) end |
Instance Method Details
#cin_arbetsformedlingen(cin) ⇒ Object
Formats a Company Identification Number the way Arbetsformedlingen likes it
44 45 46 47 48 49 |
# 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 ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# 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 |