Class: Alf::Renderer::Text

Inherits:
Alf::Renderer show all
Includes:
Utils
Defined in:
lib/alf/renderer/text.rb

Defined Under Namespace

Modules: Utils Classes: Cell, Row, Table

Constant Summary

Constants inherited from Alf::Renderer

DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Alf::Renderer

#input, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

#max

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_typeObject


5
6
7
# File 'lib/alf/renderer/text.rb', line 5

def self.mime_type
  "text/plain"
end

.render(input, output, options = {}) ⇒ Object


171
172
173
# File 'lib/alf/renderer/text.rb', line 171

def self.render(input, output, options= {})
  new(input, options).execute(output)
end

Instance Method Details

#each(&bl) ⇒ Object

class Table


161
162
163
164
165
166
167
168
169
# File 'lib/alf/renderer/text.rb', line 161

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, options)
  table.each(&bl)
end