Class: Gopher::TextContext
- Inherits:
-
Object
- Object
- Gopher::TextContext
- Defined in:
- lib/gopher.rb
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.
183 184 185 |
# File 'lib/gopher.rb', line 183 def initialize @result = "" end |
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
166 167 168 |
# File 'lib/gopher.rb', line 166 def result @result end |
Instance Method Details
#line(text) ⇒ Object
168 169 170 171 |
# File 'lib/gopher.rb', line 168 def line(text) result << text result << "\r\n" end |
#paragraph(txt, width = 70) ⇒ Object
177 178 179 180 181 |
# File 'lib/gopher.rb', line 177 def paragraph(txt, width=70) txt.each_line do |line| WordWrap.ww(line, width).each_line { |chunk| text chunk.strip } end end |
#text(text) ⇒ Object
173 174 175 |
# File 'lib/gopher.rb', line 173 def text(text) line text end |