class Gopher::MapContext
Attributes
host[RW]
port[RW]
result[RW]
Public Class Methods
new(host, port)
click to toggle source
# File lib/gopher.rb, line 192 def initialize(host, port) @host, @port = host, port @result = "" end
with_block(host, port, *args, &block)
click to toggle source
# File lib/gopher.rb, line 197 def self.with_block(host, port, *args, &block) new(host, port).instance_exec(*args, &block) end
Public Instance Methods
line(type, txt, selector, host = self.host, port = self.port)
click to toggle source
# File lib/gopher.rb, line 201 def line(type, txt, selector, host = self.host, port = self.port) result << ["#{type}#{txt}", selector, host, port].join("\t") result << "\r\n" end
link(text, selector, *args)
click to toggle source
# File lib/gopher.rb, line 206 def link(text, selector, *args) type = Gopher.determine_type(selector) line type, text, scrub(selector), *args end
map(text, selector, *args)
click to toggle source
# File lib/gopher.rb, line 211 def map(text, selector, *args) line '1', text, scrub(selector), *args end
paragraph(txt, width=70)
click to toggle source
# File lib/gopher.rb, line 219 def paragraph(txt, width=70) txt.each_line do |line| WordWrap.ww(line, width).each_line { |chunk| text chunk.strip } end end
text(text)
click to toggle source
# File lib/gopher.rb, line 215 def text(text) line 'i', text, 'false', '(NULL)', 0 end
Private Instance Methods
scrub(s)
click to toggle source
# File lib/gopher.rb, line 226 def scrub(s) "/#{s.sub(/^\/+/,'')}" end