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

- old
+ new

@@ -1,10 +1,14 @@ # -*- encoding: utf-8 -*- module TTY class Table + # Determine renderer based on terminal capabilities + # + # @return [TTY::Table::Renderer] + # # @api public def self.renderer @renderer ||= if TTY.terminal.color? TTY::Table::Renderer::Color else @@ -43,10 +47,18 @@ def initialize(options={}) super self.renderer = RENDERER_MAPPER[:"#{options[:renderer]}"].new end + # Determine renderer class based on string name + # + # @param [TTY::Table::Renderer] renderer + # the renderer used for displaying table + # + # @return [TTY::Table::Renderer] + # + # @api private def pick_renderer(renderer) if renderer RENDERER_MAPPER[renderer].new else self.renderer @@ -60,9 +72,14 @@ # @api public def renderer @renderer ||= TTY::Table.renderer.new end + # Set the renderer + # + # @return [TTY::Table::Renderer] + # + # @api private def renderer=(renderer) @renderer = renderer end delegatable_method :renderer, *RENDERER_DELEGATED_METHODS