class TZInfo::TZDataDefinition
:nodoc:
Base class for Zones and Links.
def create_file(output_dir)
Creates necessary directories, the file, writes the class header and footer
def create_file(output_dir) dir = output_dir + File::SEPARATOR + 'definitions' + File::SEPARATOR + @path_elements.join(File::SEPARATOR) FileUtils.mkdir_p(dir) File.open(output_dir + File::SEPARATOR + 'definitions' + File::SEPARATOR + @name_elements.join(File::SEPARATOR) + '.rb', 'w') {|file| file.binmode def file.indent(by) if @tz_indent @tz_indent += by else @tz_indent = by end end def file.puts(s) super("#{' ' * (@tz_indent || 0)}#{s}") end file.puts('module TZInfo') file.indent(2) file.puts('module Definitions') file.indent(2) @name_elements.each do |part| file.puts("module #{part}") file.indent(2) end file.puts('include TimezoneDefinition') file.puts('') yield file @name_elements.each do file.indent(-2) file.puts('end') end file.indent(-2) file.puts('end') # end module Definitions file.indent(-2) file.puts('end') # end module TZInfo } end
def initialize(name)
def initialize(name) @name = name # + and - aren't allowed in class names @name_elements = name.gsub(/-/, '__m__').gsub(/\+/, '__p__').split(/\//) @path_elements = @name_elements.clone @path_elements.pop end