Class: Gopher::TextContext

Inherits:
Object
  • Object
show all
Defined in:
lib/gopher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTextContext

Returns a new instance of TextContext.



184
185
186
# File 'lib/gopher.rb', line 184

def initialize
  @result = ""
end

Instance Attribute Details

#resultObject

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