Class: Alf::Renderer::Text
- Inherits:
-
Alf::Renderer
- Object
- Alf::Renderer
- Alf::Renderer::Text
- Includes:
- Utils
- Defined in:
- lib/alf-io/alf/renderer/text.rb
Defined Under Namespace
Modules: Utils Classes: Cell, Row, Table
Constant Summary
Constants inherited from Alf::Renderer
Instance Attribute Summary
Attributes inherited from Alf::Renderer
Class Method Summary collapse
Instance Method Summary collapse
-
#each(&bl) ⇒ Object
class Table.
Methods included from Utils
Methods inherited from Alf::Renderer
by_mime_type, #execute, #initialize, register, renderer
Methods included from Support::Registry
#listen, #listeners, #register, #registered
Constructor Details
This class inherits a constructor from Alf::Renderer
Class Method Details
.mime_type ⇒ Object
5 6 7 |
# File 'lib/alf-io/alf/renderer/text.rb', line 5 def self.mime_type "text/plain" end |
.render(input, output, options = {}) ⇒ Object
159 160 161 |
# File 'lib/alf-io/alf/renderer/text.rb', line 159 def self.render(input, output, = {}) new(input, ).execute(output) end |
Instance Method Details
#each(&bl) ⇒ Object
class Table
149 150 151 152 153 154 155 156 157 |
# File 'lib/alf-io/alf/renderer/text.rb', line 149 def each(&bl) input = self.input input = [input.to_hash] if TupleLike===input relation = input.to_a attrs = relation.inject([]){|memo,t| (memo | t.keys)} records = relation.map{|t| attrs.map{|a| t[a]}} table = Table.new(records, attrs, ) table.each(&bl) end |