Sha256: 4ad4164114d4447a5e5d173d657ed30d0ffa978234fab978a5a9d71e157f27b2

Contents?: true

Size: 526 Bytes

Versions: 3

Compression:

Stored size: 526 Bytes

Contents

# coding: utf-8

require 'delegate'

module TTY
  class Table
    # Structure for holding table options with indifferent access
    class Options < DelegateClass(Hash)

      def initialize(hash={}, &block)
        super(&block)

        hash.each do |key, value|
          self[convert_key(key)] = valu
        end
      end

      def []=(key, value)
        super(convert_key(key), value)
      end

      def convert_key(key)
        key.is_a?(Symbol) ? key.to_s : key
      end

    end # Options
  end # Table
end # TTY

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tty-table-0.10.0 lib/tty/table/options.rb
tty-table-0.9.0 lib/tty/table/options.rb
tty-table-0.8.0 lib/tty/table/options.rb