Class: TTY::Table::Options
- Inherits:
-
Hash
- Object
- Hash
- TTY::Table::Options
- Defined in:
- lib/tty/table/options.rb
Overview
Structure for holding table options with indifferent access
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
- #convert_key(key) ⇒ Object
-
#initialize(hash = {}, &block) ⇒ Options
constructor
A new instance of Options.
Constructor Details
#initialize(hash = {}, &block) ⇒ Options
Returns a new instance of Options.
10 11 12 13 14 15 16 |
# File 'lib/tty/table/options.rb', line 10 def initialize(hash={}, &block) super(&block) hash.each do |key, value| self[convert_key(key)] = valu end end |
Instance Method Details
#[]=(key, value) ⇒ Object
18 19 20 |
# File 'lib/tty/table/options.rb', line 18 def []=(key, value) super(convert_key(key), value) end |
#convert_key(key) ⇒ Object
22 23 24 |
# File 'lib/tty/table/options.rb', line 22 def convert_key(key) key.is_a?(Symbol) ? key.to_s : key end |