Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • rdoc/ri/ri_formatter.rb

Files

Class/Module Index [+]

Quicksearch

RI::AttributeFormatter

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

Constants

ATTR_MAP
BOLD
CODE
ITALIC

Public Instance Methods

wrap(txt, prefix=@indent, linelen=@width) click to toggle source

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

 
               # 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

bold_print(txt) click to toggle source

again, overridden

 
               # File rdoc/ri/ri_formatter.rb, line 341
def bold_print(txt)
  print txt
end
            
write_attribute_text(prefix, line) click to toggle source

overridden in specific formatters

 
               # 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