R
Rob Sanheim
Hi,
I know this can be done much cleaner and with prettier code...but I
was having trouble getting my head around doing it with collect.
"infobar_link" creates hyperlinks - it takes a 1st parameter of a
string denoting a lookup value, and an optional second string
parameter for the link text.
So "infobar_sites" is a list of sites I want to create links to, and
as you can see they can either be just a lookup value (single string),
or an array with the lookup and a title to override the default. Then
I just enumerate thru and create a list of the links.
infobar_sites = [ ["usmarket", "The Market"],
"internet",
["etf", "ETFs"],
"china",
"energy",
["ce", "Electronics"],
"media",
"gold",
"telecom",
"biotech",
"retail",
"japan",
"india" ]
output = ""
infobar_sites.each do |args|
link = nil
if args.is_a? String
link = infobar_link(args)
else
link = infobar_link(args[0], args[1])
end
output += "<li>#{ link }</li>"
end
output
any help greatly appreciated...
thanks
- Rob
I know this can be done much cleaner and with prettier code...but I
was having trouble getting my head around doing it with collect.
"infobar_link" creates hyperlinks - it takes a 1st parameter of a
string denoting a lookup value, and an optional second string
parameter for the link text.
So "infobar_sites" is a list of sites I want to create links to, and
as you can see they can either be just a lookup value (single string),
or an array with the lookup and a title to override the default. Then
I just enumerate thru and create a list of the links.
infobar_sites = [ ["usmarket", "The Market"],
"internet",
["etf", "ETFs"],
"china",
"energy",
["ce", "Electronics"],
"media",
"gold",
"telecom",
"biotech",
"retail",
"japan",
"india" ]
output = ""
infobar_sites.each do |args|
link = nil
if args.is_a? String
link = infobar_link(args)
else
link = infobar_link(args[0], args[1])
end
output += "<li>#{ link }</li>"
end
output
any help greatly appreciated...
thanks
- Rob