Class: WebCrawler::View::Base
- Inherits:
-
Object
- Object
- WebCrawler::View::Base
- Defined in:
- lib/web_crawler/view.rb
Class Attribute Summary collapse
-
.default_options ⇒ Object
Returns the value of attribute default_options.
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
- #draw(output = nil) ⇒ Object
- #format(item) ⇒ Object
-
#initialize(input, options = { }) ⇒ Base
constructor
A new instance of Base.
- #render ⇒ Object
Constructor Details
#initialize(input, options = { }) ⇒ Base
Returns a new instance of Base.
30 31 32 33 |
# File 'lib/web_crawler/view.rb', line 30 def initialize(input, = { }) @options = self.class..merge ( || { }) @input = input end |
Class Attribute Details
.default_options ⇒ Object
Returns the value of attribute default_options.
23 24 25 |
# File 'lib/web_crawler/view.rb', line 23 def @default_options end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
18 19 20 |
# File 'lib/web_crawler/view.rb', line 18 def input @input end |
Instance Method Details
#draw(output = nil) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/web_crawler/view.rb', line 39 def draw(output=nil) begin io = present_output(output) io.puts render ensure io.close if io.respond_to? :close end end |
#format(item) ⇒ Object
48 49 50 |
# File 'lib/web_crawler/view.rb', line 48 def format(item) item end |
#render ⇒ Object
35 36 37 |
# File 'lib/web_crawler/view.rb', line 35 def render [*input].map { |i| format(i) }.join end |