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.
191 192 193 194 |
# File 'lib/gopher.rb', line 191 def initialize(host, port) @host, @port = host, port @result = "" end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
189 190 191 |
# File 'lib/gopher.rb', line 189 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
189 190 191 |
# File 'lib/gopher.rb', line 189 def port @port end |
#result ⇒ Object
Returns the value of attribute result.
189 190 191 |
# File 'lib/gopher.rb', line 189 def result @result end |
Class Method Details
.with_block(host, port, *args, &block) ⇒ Object
196 197 198 |
# File 'lib/gopher.rb', line 196 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
200 201 202 203 |
# File 'lib/gopher.rb', line 200 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
205 206 207 208 |
# File 'lib/gopher.rb', line 205 def link(text, selector, *args) type = Gopher.determine_type(selector) line type, text, scrub(selector), *args end |
#map(text, selector, *args) ⇒ Object
210 211 212 |
# File 'lib/gopher.rb', line 210 def map(text, selector, *args) line '1', text, scrub(selector), *args end |
#paragraph(txt, width = 70) ⇒ Object
218 219 220 221 222 |
# File 'lib/gopher.rb', line 218 def paragraph(txt, width=70) txt.each_line do |line| Textwrap.wrap(line, width).each { |chunk| text chunk } end end |
#text(text) ⇒ Object
214 215 216 |
# File 'lib/gopher.rb', line 214 def text(text) line 'i', text, 'false', '(NULL)', 0 end |