Introducing the ruby_kml gem

require 'ruby_kml'

kml = KMLFile.new
folder = KML::Folder.new(:name => 'Melbourne Stations')
[
  ["Flinders St",    -37.818078, 144.966811],
  ["Southern Cross", -37.818358, 144.952417],
].each do |name, lat, lng|
  folder.features << KML::Placemark.new(
    :name => name,
    :geometry => KML::Point.new(:coordinates => {:lat => lat, :lng => lng})
  )
end
kml.objects << folder
puts kml.render

output:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
  <Folder>
    <name>Melbourne Stations</name>
    <Placemark>
      <name>Flinders St</name>
      <Point>
        <coordinates>144.966811,-37.818078</coordinates>
      </Point>
    </Placemark>
    <Placemark>
      <name>Southern Cross</name>
      <Point>
        <coordinates>144.952417,-37.818358</coordinates>
      </Point>
    </Placemark>
  </Folder>
</kml>
Tags:
Source:
1008hrs.txt
Published:
08-08-2014 10:08