Ruby Programming Help

Hey Everyone
I need your help regarding ruby programming. I have two classes.
1) Companies Class
2) Writer Class
I want to generate a site-map XML file according to the companies names.
In the Companies class I get the data about companies and I want to pass
it to the writer class to write site-map
Following are the classes... Anyone plz help me its very urgent
++++++++++++++Companies Class++++++++++++++
module Sitemap
=begin
Class Name: Companies
Function: This class is responsible for getting the data and passing it
to write.
=end
  class Companies

    def initialize(country_version, directory, country_host)
      @country_version = country_version
      @directory = directory
      @country_host = country_host
      yield_data
    end

    #def slices
      #CountryVersion.each do |cv|
        #yield :country_version => cv
      #end
    #end

    def yield_data
      Company.find_each(:conditions => {:country_version_id =>
@country_version.id}) do |company|
        yield entry(company)
      end
    end

    private
    def entry(company)
      Entry.new(
        :url =>
ActionController::Integration::Session.new.url_for(:controller =>
'companies', :action => 'show', :company_name => company.name, :host =>
@country_host.value),
        :filepath => @directory + "companies_sitemap.xml",
        :frequency => 0.8,
        :priority => 'monthly'
      )
    end
  end
end

+++++++++++Writer++++++++++++

module Sitemap
=begin
Class Name: Writer
Function: This class is responsible for creating the sitemap for each
country
version.
=end
  class Writer
    include ActionController::UrlWriter

    def initialize(filepath)
      @filepath=filepath
    end

    def self.generate(filepath,&block)
      writer = new(filepath)
      writer.fill(&block)
    end

    def fill
        File.open(@filepath,"w") do |f|
          f.write(%[<?xml version="1.0" encoding="UTF-8"?>\n])
          f.write(%[<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n])
          yield self
          f.write(%[</urlset>])
          f.close
        end
        zipped_file = 'gzip -f #{@filename}'
        return zipped_file
    end

    def write_entry(entry)
      xml.url do
        xml.loc entry.url
        xml.lastmod entry.lastmod
        xml.changefreq entry.frequency
        xml.priority entry.priority
      end
    end

  end
end

···

--
Posted via http://www.ruby-forum.com/.

Hey Everyone
I need your help regarding ruby programming.

http://www.catb.org/~esr/faqs/smart-questions.html#courtesy

I have two classes.
1) Companies Class
2) Writer Class
I want to generate a site-map XML file according to the companies names.
In the Companies class I get the data about companies and I want to pass
it to the writer class to write site-map
Following are the classes... Anyone plz help me its very urgent

http://www.catb.org/~esr/faqs/smart-questions.html#urgent

++++++++++++++Companies Class++++++++++++++

+++++++++++Writer++++++++++++

http://www.catb.org/~esr/faqs/smart-questions.html#volume

And the question is?

http://www.catb.org/~esr/faqs/smart-questions.html#beprecise
http://www.catb.org/~esr/faqs/smart-questions.html#explicit

And, just in case

http://www.catb.org/~esr/faqs/smart-questions.html#homework

Cheers

robert

···

On Wed, Dec 21, 2011 at 1:01 PM, umair iqbal <wearybands@gmail.com> wrote:

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/