lib/tty/table/renderer.rb in tty-0.0.4 vs lib/tty/table/renderer.rb in tty-0.0.5

- old
+ new

@@ -27,43 +27,40 @@ # # @api public module Renderer extend TTY::Delegatable + autoload :ASCII, 'tty/table/renderer/ascii' autoload :Basic, 'tty/table/renderer/basic' autoload :Color, 'tty/table/renderer/color' autoload :Unicode, 'tty/table/renderer/unicode' - RENDERER_DELEGATED_METHODS = [ :render, :extract_column_widths, :total_width] + RENDERER_DELEGATED_METHODS = [ :render, :total_width] RENDERER_MAPPER = { + :ascii => TTY::Table::Renderer::ASCII, :basic => TTY::Table::Renderer::Basic, :color => TTY::Table::Renderer::Color, :unicode => TTY::Table::Renderer::Unicode } # Initialize a Renderer # # @api private def initialize(options={}) - super - self.renderer = RENDERER_MAPPER[:"#{options[:renderer]}"].new + super() end # Determine renderer class based on string name # - # @param [TTY::Table::Renderer] renderer - # the renderer used for displaying table + # @param [Symbol] renderer + # the renderer used for displaying table out of [:basic, :color, :unicode] # # @return [TTY::Table::Renderer] # # @api private - def pick_renderer(renderer) - if renderer - RENDERER_MAPPER[renderer].new - else - self.renderer - end + def pick_renderer(type=nil) + type ? RENDERER_MAPPER[type].new : self.renderer end # Return the default renderer # # @return [TTY::Table::Renderer]