Class: Gopher::MapContext
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#result ⇒ Object
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(host, port) ⇒ MapContext
constructor
A new instance of MapContext.
- #line(type, txt, selector, host = host, port = port) ⇒ Object
- #link(text, selector, *args) ⇒ Object
- #map(text, selector, *args) ⇒ Object
- #paragraph(txt, width = 70) ⇒ Object
- #text(text) ⇒ Object
Constructor Details
#initialize(host, port) ⇒ MapContext
Returns a new instance of MapContext.
189 190 191 192 |
# File 'lib/gopher.rb', line 189 def initialize(host, port) @host, @port = host, port @result = "" end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
187 188 189 |
# File 'lib/gopher.rb', line 187 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
187 188 189 |
# File 'lib/gopher.rb', line 187 def port @port end |
#result ⇒ Object
Returns the value of attribute result.
187 188 189 |
# File 'lib/gopher.rb', line 187 def result @result end |
Class Method Details
.with_block(host, port, *args, &block) ⇒ Object
194 195 196 |
# File 'lib/gopher.rb', line 194 def self.with_block(host, port, *args, &block) new(host, port).instance_exec(*args, &block) end |
Instance Method Details
#line(type, txt, selector, host = host, port = port) ⇒ Object
198 199 200 201 |
# File 'lib/gopher.rb', line 198 def line(type, txt, selector, host = host, port = port) result << ["#{type}#{txt}", selector, host, port].join("\t") result << "\r\n" end |
#link(text, selector, *args) ⇒ Object
203 204 205 206 |
# File 'lib/gopher.rb', line 203 def link(text, selector, *args) type = Gopher.determine_type(selector) line type, text, scrub(selector), *args end |
#map(text, selector, *args) ⇒ Object
208 209 210 |
# File 'lib/gopher.rb', line 208 def map(text, selector, *args) line '1', text, scrub(selector), *args end |
#paragraph(txt, width = 70) ⇒ Object
216 217 218 219 220 |
# File 'lib/gopher.rb', line 216 def paragraph(txt, width=70) txt.each_line do |line| Textwrap.wrap(line, width).each { |chunk| text chunk } end end |
#text(text) ⇒ Object
212 213 214 |
# File 'lib/gopher.rb', line 212 def text(text) line 'i', text, 'false', '(NULL)', 0 end |