Class: PlainGenerator

Inherits:
RWEB::Generator show all
Defined in:
lib/rweb.rb

Overview

PlainGenerator is a simple object that does very little processing on code and/or document lines. Its implementation is similarly simple.

Instance Attribute Summary

Attributes inherited from RWEB::Generator

#directives, #docs, #style

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ PlainGenerator

The initialize function just sets the style and does no other preparation.



362
363
364
365
# File 'lib/rweb.rb', line 362

def initialize(*args)
  @style = "Plain"
  super
end

Instance Method Details

#code(chunk) ⇒ Object

The chunk function prints out the name and “single-underlines” it, then follows through with printing each code line with pre-pended “chicken feet”.



374
375
376
377
# File 'lib/rweb.rb', line 374

def code(chunk)
  "#{chunk.name}\n" "#{"-"*chunk.name.length}\n" +
    chunk.map { |line| "> " + line}.to_s
end

#doc(chunk) ⇒ Object

The doc function passes the documentation chunk through unchanged.



380
381
382
# File 'lib/rweb.rb', line 380

def doc(chunk)
  chunk.to_s
end

The footer function does nothing.



385
386
387
# File 'lib/rweb.rb', line 385

def footer
  ""
end

#header(title) ⇒ Object

The header function prints out the title and then “double-underlines” it.



368
369
370
# File 'lib/rweb.rb', line 368

def header(title)
  "#{title}\n" "#{"="*title.length}\n"
end