Method: CrmFormatter::Wrap#format_data

Defined in:
lib/crm_formatter/wrap.rb

#format_dataObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/crm_formatter/wrap.rb', line 32

def format_data
  return unless @crm_data[:data][:valid_data].any?
  adr_obj = CrmFormatter::Address.new
  phone_obj = CrmFormatter::Phone.new
  web_obj = CrmFormatter::Web.new

  @crm_data[:data][:valid_data].map! do |valid_hash|
    local_hash = @global_hash
    crmf_url_hsh = web_obj.format_url(valid_hash[:url])
    crmf_phone_hsh = phone_obj.validate_phone(valid_hash[:phone])

    adr_hsh = valid_hash.slice(:street, :city, :state, :zip)
    crmf_adr_hsh = adr_obj.format_full_address(adr_hsh)
    local_hash = local_hash.merge(valid_hash)
    local_hash = local_hash.merge(crmf_url_hsh)
    local_hash = local_hash.merge(crmf_phone_hsh)
    local_hash = local_hash.merge(crmf_adr_hsh)
    local_hash
  end
end