Class RI::AttributeFormatter
In: rdoc/ri/ri_formatter.rb
Parent: TextFormatter

Handle text with attributes. We‘re a base class: there are different presentation classes (one, for example, uses overstrikes to handle bold and underlining, while another using ANSI escape sequences

Methods

Classes and Modules

Class RI::AttributeFormatter::AttrChar
Class RI::AttributeFormatter::AttributeString

Constants

BOLD = 1
ITALIC = 2
CODE = 4
ATTR_MAP = { "b" => BOLD, "code" => CODE, "em" => ITALIC, "i" => ITALIC, "tt" => CODE

Public Instance methods

overrides base class. Looks for etc sequences and generates an array of AttrChars. This array is then used as the basis for the split

[Source]

# File rdoc/ri/ri_formatter.rb, line 305
    def wrap(txt,  prefix=@indent, linelen=@width)
      return unless txt && !txt.empty?

      txt = add_attributes_to(txt)
      next_prefix = prefix.tr("^ ", " ")
      linelen -= prefix.size

      line = []

      until txt.empty?
        word = txt.next_word
        if word.size + line.size > linelen
          write_attribute_text(prefix, line)
          prefix = next_prefix
          line = []
        end
        line.concat(word)
      end

      write_attribute_text(prefix, line) if line.length > 0
    end

Protected Instance methods

again, overridden

[Source]

# File rdoc/ri/ri_formatter.rb, line 341
    def bold_print(txt)
      print txt
    end

overridden in specific formatters

[Source]

# File rdoc/ri/ri_formatter.rb, line 331
    def write_attribute_text(prefix, line)
      print prefix
      line.each do |achar|
        print achar.char
      end
      puts
    end

[Validate]

ruby-doc.org is hosted and maintained by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.