Class: Gopher::MapContext
- Inherits:
-
Object
- Object
- Gopher::MapContext
- Defined in:
- lib/gopher.rb
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 = self.host, port = self.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.
192 193 194 195 |
# File 'lib/gopher.rb', line 192 def initialize(host, port) @host, @port = host, port @result = "" end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
190 191 192 |
# File 'lib/gopher.rb', line 190 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
190 191 192 |
# File 'lib/gopher.rb', line 190 def port @port end |
#result ⇒ Object
Returns the value of attribute result.
190 191 192 |
# File 'lib/gopher.rb', line 190 def result @result end |
Class Method Details
.with_block(host, port, *args, &block) ⇒ Object
197 198 199 |
# File 'lib/gopher.rb', line 197 def self.with_block(host, port, *args, &block) new(host, port).instance_exec(*args, &block) end |
Instance Method Details
#line(type, txt, selector, host = self.host, port = self.port) ⇒ Object
201 202 203 204 |
# 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) ⇒ Object
206 207 208 209 |
# 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) ⇒ Object
211 212 213 |
# File 'lib/gopher.rb', line 211 def map(text, selector, *args) line '1', text, scrub(selector), *args end |
#paragraph(txt, width = 70) ⇒ Object
219 220 221 222 223 |
# 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) ⇒ Object
215 216 217 |
# File 'lib/gopher.rb', line 215 def text(text) line 'i', text, 'false', '(NULL)', 0 end |