thelivingphoenix
Member
I'm not sure if this is the right forum for this or not... I wasn't sure where else to put it, if anywhere.
Anyway, what I'm trying to do right now is generate a series of web pages from a list of cities in an array using Ruby. The thing is, I need to have around 30 links in the footer and they need to be random for each page that is generated. I figured out how to generate random links and they print in the command line, but they don't save to the file like I need them to. -_-
Of course, it's supposed to say "a href" and [/url] isn't supposed to be in there... >.>;;
When the file is created, it just says "30". I can't figure out how to get it to print the random 30 links to the file... can someone help, please? I know there's a Ruby person here somewhere that can help meh.
Anyway, what I'm trying to do right now is generate a series of web pages from a list of cities in an array using Ruby. The thing is, I need to have around 30 links in the footer and they need to be random for each page that is generated. I figured out how to generate random links and they print in the command line, but they don't save to the file like I need them to. -_-
def insertlink
cities = ['Alachua',
'Altamonte Springs',
'Apalachicola',
'Apopka',
'Arcadia',
'Atlantic Beach',
'Auburndale',
'Avon Park',
'Bartow',
'Belle Glade',
'Belleview',
'Beverly Hills',
'Big Pine Key',
'Blountstown',
'Boca Raton',
'Bonifay',
'Bonita Springs',
'Boynton Beach',
'Bradenton',
'Brandon',
'Brooksville',
'Bunnell',
'Bushnell',
'Callahan',
'Cantonment',
'Cape Canaveral',
'Cape Coral',
'Casselberry',
'Chiefland',
'Chipley',
'Clearwater',
'Clermont',
'Clewiston',
'Cocoa',
'Cocoa Beach',
'Crawfordville',
'Crestview',
'Crystal River',
'Dade City',
'Dania',
'Daytona Beach',
'Debary',
'Deerfield Beach',
'Defuniak Springs',
'Deland',
'Delray Beach',
'Deltona',
'Destin',
'Dunedin',
'Dunnellon',
'Eastpoint',
'Edgewater',
'Englewood',
'Estero',
'Eustis',
'Fernandina Beach',
'Flagler Beach',
'Fort Myers',
'Fort Myers Beach',
'Fort Pierce',
'Fort Walton Beach',
'Gainesville',
'Green',
'Cove Springs',
'Groveland',
'Gulf Breeze',
'Haines City',
'Hallandale',
'Havana',
'Hernando',
'High Springs',
'Hobe Sound',
'Holiday',
'Hollywood',
'Etc.'
]
city = cities[rand(cities.length)]
puts %Q{<a hr ef="http://www.website.com/cities/florida/website#{city.delete " "}.html">#{city}</a> | }
end
output = 30.times do
insertlink
end
File:pen("I:\\My Stuff\\Current Desktop Stuff\\generated florida pages\\sitelinks.html", 'w') do |f|
f.write output
end
cities = ['Alachua',
'Altamonte Springs',
'Apalachicola',
'Apopka',
'Arcadia',
'Atlantic Beach',
'Auburndale',
'Avon Park',
'Bartow',
'Belle Glade',
'Belleview',
'Beverly Hills',
'Big Pine Key',
'Blountstown',
'Boca Raton',
'Bonifay',
'Bonita Springs',
'Boynton Beach',
'Bradenton',
'Brandon',
'Brooksville',
'Bunnell',
'Bushnell',
'Callahan',
'Cantonment',
'Cape Canaveral',
'Cape Coral',
'Casselberry',
'Chiefland',
'Chipley',
'Clearwater',
'Clermont',
'Clewiston',
'Cocoa',
'Cocoa Beach',
'Crawfordville',
'Crestview',
'Crystal River',
'Dade City',
'Dania',
'Daytona Beach',
'Debary',
'Deerfield Beach',
'Defuniak Springs',
'Deland',
'Delray Beach',
'Deltona',
'Destin',
'Dunedin',
'Dunnellon',
'Eastpoint',
'Edgewater',
'Englewood',
'Estero',
'Eustis',
'Fernandina Beach',
'Flagler Beach',
'Fort Myers',
'Fort Myers Beach',
'Fort Pierce',
'Fort Walton Beach',
'Gainesville',
'Green',
'Cove Springs',
'Groveland',
'Gulf Breeze',
'Haines City',
'Hallandale',
'Havana',
'Hernando',
'High Springs',
'Hobe Sound',
'Holiday',
'Hollywood',
'Etc.'
]
city = cities[rand(cities.length)]
puts %Q{<a hr ef="http://www.website.com/cities/florida/website#{city.delete " "}.html">#{city}</a> | }
end
output = 30.times do
insertlink
end
File:pen("I:\\My Stuff\\Current Desktop Stuff\\generated florida pages\\sitelinks.html", 'w') do |f|
f.write output
end
Of course, it's supposed to say "a href" and [/url] isn't supposed to be in there... >.>;;
When the file is created, it just says "30". I can't figure out how to get it to print the random 30 links to the file... can someone help, please? I know there's a Ruby person here somewhere that can help meh.