Class | RI::RiWriter
In: | rdoc/ri/ri_writer.rb
Parent: | Object

### Methods

add_class add_method class_desc_path external_to_internal internal_to_external new remove_class

### Public Class methods

class_desc_path(dir, class_desc)

[Source]

    # File rdoc/ri/ri_writer.rb, line 6
        def RiWriter.class_desc_path(dir, class_desc)
          File.join(dir, "cdesc-" + class_desc.name + ".yaml")
        end

external_to_internal(name)

And the reverse operation

[Source]

    # File rdoc/ri/ri_writer.rb, line 20
        def RiWriter.external_to_internal(name)
          name.gsub(/%([0-9a-f]{2,2})/) { $1.to_i(16).chr }
        end

internal_to_external(name)

Convert a name from internal form (containing punctuation) to an external form (where punctuation is replaced by %xx)

[Source]

    # File rdoc/ri/ri_writer.rb, line 15
        def RiWriter.internal_to_external(name)
          name.gsub(/\W/) { sprintf("%%%02x", $&[0]) }
        end

new(base_dir)

[Source]

    # File rdoc/ri/ri_writer.rb, line 24
        def initialize(base_dir)
          @base_dir = base_dir
        end

### Public Instance methods

add_class(class_desc)

[Source]

    # File rdoc/ri/ri_writer.rb, line 32
        def add_class(class_desc)
          dir = path_to_dir(class_desc.full_name)
          FileUtils.mkdir_p(dir)
          class_file_name = RiWriter.class_desc_path(dir, class_desc)
          File.open(class_file_name, "w") do |f|
            f.write(class_desc.serialize)
          end
        end

add_method(class_desc, method_desc)

[Source]

    # File rdoc/ri/ri_writer.rb, line 41
        def add_method(class_desc, method_desc)
          dir = path_to_dir(class_desc.full_name)
          file_name = RiWriter.internal_to_external(method_desc.name)
          meth_file_name = File.join(dir, file_name)
          if method_desc.is_singleton
            meth_file_name += "-c.yaml"
          else
            meth_file_name += "-i.yaml"
          end

          File.open(meth_file_name, "w") do |f|
            f.write(method_desc.serialize)
          end
        end

remove_class(class_desc)

[Source]

    # File rdoc/ri/ri_writer.rb, line 28
        def remove_class(class_desc)
          FileUtils.rm_rf(path_to_dir(class_desc.full_name))
        end

[Validate]