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.
184 185 186 |
# File 'lib/gopher.rb', line 184 def initialize @result = "" end |
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
167 168 169 |
# File 'lib/gopher.rb', line 167 def result @result end |
Instance Method Details
#line(text) ⇒ Object
169 170 171 172 |
# File 'lib/gopher.rb', line 169 def line(text) result << text result << "\r\n" end |
#paragraph(txt, width = 70) ⇒ Object
178 179 180 181 182 |
# File 'lib/gopher.rb', line 178 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
174 175 176 |
# File 'lib/gopher.rb', line 174 def text(text) line text end |