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.



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

def initialize
  @result = ""
end

Instance Attribute Details

#resultObject

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