Class: Gopher::TextContext
Instance Attribute Summary collapse
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize ⇒ TextContext
constructor
A new instance of TextContext.
- #line(text) ⇒ Object
- #paragraph(txt, width = 70) ⇒ Object
- #text(text) ⇒ Object
Constructor Details
#initialize ⇒ TextContext
Returns a new instance of TextContext.
181 182 183 |
# File 'lib/gopher.rb', line 181 def initialize @result = "" end |
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
164 165 166 |
# File 'lib/gopher.rb', line 164 def result @result end |
Instance Method Details
#line(text) ⇒ Object
166 167 168 169 |
# File 'lib/gopher.rb', line 166 def line(text) result << text result << "\r\n" end |
#paragraph(txt, width = 70) ⇒ Object
175 176 177 178 179 |
# File 'lib/gopher.rb', line 175 def paragraph(txt, width=70) txt.each_line do |line| Textwrap.wrap(line, width).each { |chunk| text chunk } end end |
#text(text) ⇒ Object
171 172 173 |
# File 'lib/gopher.rb', line 171 def text(text) line text end |