Class: Choosy::Printing::Manpage
- Inherits:
-
Object
- Object
- Choosy::Printing::Manpage
- Defined in:
- lib/choosy/printing/manpage.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#date ⇒ Object
Returns the value of attribute date.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#manual ⇒ Object
Returns the value of attribute manual.
-
#name ⇒ Object
Returns the value of attribute name.
-
#section ⇒ Object
Returns the value of attribute section.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #bold(line, type = nil) ⇒ Object
- #comment(line) ⇒ Object
- #fill ⇒ Object
- #frame_outline ⇒ Object
- #hanging_paragraph(line) ⇒ Object
- #indented_paragraph(item, line) ⇒ Object
- #indented_region ⇒ Object
-
#initialize ⇒ Manpage
constructor
A new instance of Manpage.
- #italics(line, type = nil) ⇒ Object
- #line_break ⇒ Object
- #nofill(&block) ⇒ Object
- #paragraph(line = nil) ⇒ Object
- #raw(line) ⇒ Object
- #roman(line, type) ⇒ Object
- #section_heading(line) ⇒ Object
- #small(line, type = nil) ⇒ Object
- #subsection_heading(line) ⇒ Object
- #term_paragraph(term, para, width = 5) ⇒ Object
- #text(line) ⇒ Object
- #to_s(io = nil) ⇒ Object
Constructor Details
#initialize ⇒ Manpage
Returns a new instance of Manpage.
38 39 40 41 42 43 44 45 |
# File 'lib/choosy/printing/manpage.rb', line 38 def initialize @buffer = [] @section = 1 @format = ManpageFormatter.new @version = nil @date = nil @manual = nil end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
36 37 38 |
# File 'lib/choosy/printing/manpage.rb', line 36 def buffer @buffer end |
#date ⇒ Object
Returns the value of attribute date.
35 36 37 |
# File 'lib/choosy/printing/manpage.rb', line 35 def date @date end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
36 37 38 |
# File 'lib/choosy/printing/manpage.rb', line 36 def format @format end |
#manual ⇒ Object
Returns the value of attribute manual.
35 36 37 |
# File 'lib/choosy/printing/manpage.rb', line 35 def manual @manual end |
#name ⇒ Object
Returns the value of attribute name.
35 36 37 |
# File 'lib/choosy/printing/manpage.rb', line 35 def name @name end |
#section ⇒ Object
Returns the value of attribute section.
35 36 37 |
# File 'lib/choosy/printing/manpage.rb', line 35 def section @section end |
#version ⇒ Object
Returns the value of attribute version.
35 36 37 |
# File 'lib/choosy/printing/manpage.rb', line 35 def version @version end |
Instance Method Details
#bold(line, type = nil) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/choosy/printing/manpage.rb', line 96 def bold(line, type=nil) line = escape(line) case type when nil prefixed('.B', line) when :italics prefixed('.BI', line) when :roman prefixed('.BR', line) else raise Choosy::ConfigurationError.new("Undefined manpage bold type: #{type}") end end |
#comment(line) ⇒ Object
148 149 150 |
# File 'lib/choosy/printing/manpage.rb', line 148 def comment(line) append('.\\" ' << line) end |
#fill ⇒ Object
166 167 168 |
# File 'lib/choosy/printing/manpage.rb', line 166 def fill append('.fi') end |
#frame_outline ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/choosy/printing/manpage.rb', line 47 def frame_outline frame = ".TH" quote(frame, @name) quote(frame, @section) quote(frame, @date) quote(frame, @version) quote(frame, @manual) frame end |
#hanging_paragraph(line) ⇒ Object
78 79 80 |
# File 'lib/choosy/printing/manpage.rb', line 78 def hanging_paragraph(line) append(".HP\n" << escape(line)) end |
#indented_paragraph(item, line) ⇒ Object
74 75 76 |
# File 'lib/choosy/printing/manpage.rb', line 74 def indented_paragraph(item, line) prefixed('.IP', escape(item), escape(line)) end |
#indented_region ⇒ Object
82 83 84 |
# File 'lib/choosy/printing/manpage.rb', line 82 def indented_region append('.RE') end |
#italics(line, type = nil) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/choosy/printing/manpage.rb', line 110 def italics(line, type=nil) line = escape(line) case type when nil prefixed('.I', line) when :bold prefixed('.IB', line) when :roman prefixed('.IR', line) else raise Choosy::ConfigurationError.new("Undefined manpage italics type: #{type}") end end |
#line_break ⇒ Object
152 153 154 |
# File 'lib/choosy/printing/manpage.rb', line 152 def line_break append('.br') end |
#nofill(&block) ⇒ Object
156 157 158 159 160 161 162 163 164 |
# File 'lib/choosy/printing/manpage.rb', line 156 def nofill(&block) if block_given? append('.nf') yield self append('.fi') else append('.nf') end end |
#paragraph(line = nil) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/choosy/printing/manpage.rb', line 65 def paragraph(line=nil) line = if line.nil? '.P' else ".P\n" << line end append(line) end |
#raw(line) ⇒ Object
91 92 93 94 |
# File 'lib/choosy/printing/manpage.rb', line 91 def raw(line) return if line.nil? append(line) end |
#roman(line, type) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/choosy/printing/manpage.rb', line 124 def roman(line, type) line = escape(line) case type when :italics prefixed('.RI', line) when :bold prefixed('.RB', line) else raise Choosy::ConfigurationError.new("Undefined manpage for roman type: #{type}") end end |
#section_heading(line) ⇒ Object
57 58 59 |
# File 'lib/choosy/printing/manpage.rb', line 57 def section_heading(line) prefixed('.SH', heading(line)) end |
#small(line, type = nil) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/choosy/printing/manpage.rb', line 136 def small(line, type=nil) line = escape(line) case type when nil prefixed('.SM', line) when :bold prefixed('.SB', line) else raise Choosy::ConfigurationError.new("Undefined manpage for small type: #{type}") end end |
#subsection_heading(line) ⇒ Object
61 62 63 |
# File 'lib/choosy/printing/manpage.rb', line 61 def subsection_heading(line) prefixed('.SS', heading(line)) end |
#term_paragraph(term, para, width = 5) ⇒ Object
170 171 172 |
# File 'lib/choosy/printing/manpage.rb', line 170 def term_paragraph(term, para, width=5) append(".TP " << width.to_s << NEWLINE << escape(term) << NEWLINE << escape(para)) end |
#text(line) ⇒ Object
86 87 88 89 |
# File 'lib/choosy/printing/manpage.rb', line 86 def text(line) return if line.nil? append(escape(line)) end |
#to_s(io = nil) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/choosy/printing/manpage.rb', line 174 def to_s(io=nil) io ||= "" io << "'\\\" t\n" io << frame_outline << NEWLINE io << PREFACE @buffer.each do |line| io << line io << NEWLINE end io end |