Class: Gopher::TextContext

Inherits:
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.



181
182
183
# File 'lib/gopher.rb', line 181

def initialize
  @result = ""
end

Instance Attribute Details

#resultObject

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