Inserting hash data into email

Morning all,

What is the best way to insert hash data into an email? I have tried
several different ways and I either get can’t convert array to a string
or private method ‘chomp’. Below is the code I am currently using.

Tim

class SktyFut
attr_reader :acct

def initialize(filename)
@acct = File.new(filename, “r”)
end

def future_data
@sktylist = Hash.new(0)
@acct.each do |list|
office = list[21…23]
if office == “RPT”
next
else
acctnum = list[24…28]
end
lv = list[217…230]
is_negative = list[215,1] == “-”
value = lv.to_f/100
value = -value if is_negative

  # Add vales to hash

  @sktylist[acctnum] += value
end
return @sktylist

end
end

class Calculate
attr_reader :sktyfuta, :sktyfutb
def initialize(sktyfuta, sktyfutb)
@sktyfuta = sktyfuta
@sktyfutb = sktyfutb
end

def data_comp
@sktyfuta.merge(@sktyfutb) { |key, old_value, new_value| old_value -
new_value }
end
#end
end

class FinalNum
attr_reader :sktynl
def initialize(sktynl)
@sktynl = sktynl
end

def numbers
@nat = Hash.new(0)
@sktynl.each do |key, value|
key.to_s
if key <= “739”
key = “SKTY” # =>
@nat[key] += value
elsif key >=“740”
key = “SKYNY” # =>
@nat[key] += value
end
end
return @nat
end
end

Dir.chdir(“/Users/twolak”)
post = SktyFut.new(“SKTYBal20080507.txt”)
a = post.future_data
#a.sort!
a.each{|key, value| puts “#{key} A value is #{value}”}
pre = SktyFut.new(“SKTYBal20080506.txt”)
b = pre.future_data
data = Calculate.new(a,b)
iteration = data.data_comp
#iteration.sort
#iteration.each{|key, value| puts “#{key} comp equals #{value}” }
sktyfinal = FinalNum.new(iteration)
cody = sktyfinal.numbers
cody.each{ |key, value| puts “#{key} line is #{value}” }
cody.to_s

require ‘net/smtp’

Net::SMTP.start(‘sktymx1.sktydev.com’, 25) do |smtp|
smtp.open_message_stream(‘[email protected]’,
[‘[email protected]’]) do |f|
f.puts ‘From: [email protected]
f.puts ‘To: [email protected]
f.puts ‘Subject: test message’
f.puts
f.puts cody.each{ |key, value| puts “#{key} line is #{value}” }
f.puts ‘This is a test message.’
end
end