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.
-
#column_width ⇒ Object
Returns the value of attribute column_width.
-
#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.
37 38 39 40 41 42 43 44 |
# File 'lib/choosy/printing/manpage.rb', line 37 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.
34 35 36 |
# File 'lib/choosy/printing/manpage.rb', line 34 def buffer @buffer end |
#column_width ⇒ Object
Returns the value of attribute column_width.
35 36 37 |
# File 'lib/choosy/printing/manpage.rb', line 35 def column_width @column_width end |
#date ⇒ Object
Returns the value of attribute date.
33 34 35 |
# File 'lib/choosy/printing/manpage.rb', line 33 def date @date end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
34 35 36 |
# File 'lib/choosy/printing/manpage.rb', line 34 def format @format end |
#manual ⇒ Object
Returns the value of attribute manual.
33 34 35 |
# File 'lib/choosy/printing/manpage.rb', line 33 def manual @manual end |
#name ⇒ Object
Returns the value of attribute name.
33 34 35 |
# File 'lib/choosy/printing/manpage.rb', line 33 def name @name end |
#section ⇒ Object
Returns the value of attribute section.
33 34 35 |
# File 'lib/choosy/printing/manpage.rb', line 33 def section @section end |
#version ⇒ Object
Returns the value of attribute version.
33 34 35 |
# File 'lib/choosy/printing/manpage.rb', line 33 def version @version end |
Instance Method Details
#bold(line, type = nil) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/choosy/printing/manpage.rb', line 95 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
147 148 149 |
# File 'lib/choosy/printing/manpage.rb', line 147 def comment(line) append('.\\" ' << line) end |
#fill ⇒ Object
165 166 167 |
# File 'lib/choosy/printing/manpage.rb', line 165 def fill append('.fi') end |
#frame_outline ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/choosy/printing/manpage.rb', line 46 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
77 78 79 |
# File 'lib/choosy/printing/manpage.rb', line 77 def hanging_paragraph(line) append(".HP\n" << escape(line)) end |
#indented_paragraph(item, line) ⇒ Object
73 74 75 |
# File 'lib/choosy/printing/manpage.rb', line 73 def indented_paragraph(item, line) prefixed('.IP', escape(item), escape(line)) end |
#indented_region ⇒ Object
81 82 83 |
# File 'lib/choosy/printing/manpage.rb', line 81 def indented_region append('.RE') end |
#italics(line, type = nil) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/choosy/printing/manpage.rb', line 109 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
151 152 153 |
# File 'lib/choosy/printing/manpage.rb', line 151 def line_break append('.br') end |
#nofill(&block) ⇒ Object
155 156 157 158 159 160 161 162 163 |
# File 'lib/choosy/printing/manpage.rb', line 155 def nofill(&block) if block_given? append('.nf') yield self append('.fi') else append('.nf') end end |
#paragraph(line = nil) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/choosy/printing/manpage.rb', line 64 def paragraph(line=nil) line = if line.nil? '.P' else ".P\n" << line end append(line) end |
#raw(line) ⇒ Object
90 91 92 93 |
# File 'lib/choosy/printing/manpage.rb', line 90 def raw(line) return if line.nil? append(line) end |
#roman(line, type) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/choosy/printing/manpage.rb', line 123 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
56 57 58 |
# File 'lib/choosy/printing/manpage.rb', line 56 def section_heading(line) prefixed('.SH', heading(line)) end |
#small(line, type = nil) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/choosy/printing/manpage.rb', line 135 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
60 61 62 |
# File 'lib/choosy/printing/manpage.rb', line 60 def subsection_heading(line) prefixed('.SS', heading(line)) end |
#term_paragraph(term, para, width = 5) ⇒ Object
169 170 171 |
# File 'lib/choosy/printing/manpage.rb', line 169 def term_paragraph(term, para, width=5) append(".TP " << width.to_s << NEWLINE << escape(term) << NEWLINE << escape(para)) end |
#text(line) ⇒ Object
85 86 87 88 |
# File 'lib/choosy/printing/manpage.rb', line 85 def text(line) return if line.nil? append(escape(line)) end |
#to_s(io = nil) ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/choosy/printing/manpage.rb', line 173 def to_s(io=nil) io ||= "" io << "'\\\" t\n" io << frame_outline << NEWLINE io << PREFACE if column_width io << ".ll " << column_width.to_s << NEWLINE end @buffer.each do |line| io << line io << NEWLINE end io end |