Class: TTY::Table::BorderOptions
- Inherits:
-
Struct
- Object
- Struct
- TTY::Table::BorderOptions
- Defined in:
- lib/tty/table/border_options.rb
Overview
A class that represents table border options
Instance Attribute Summary collapse
-
#characters ⇒ Object
Returns the value of attribute characters.
-
#separator ⇒ Object
Returns the value of attribute separator.
-
#style ⇒ Object
Returns the value of attribute style.
Class Method Summary collapse
-
.from(value) ⇒ Object
Create options instance from hash.
Instance Method Summary collapse
-
#initialize(*args) ⇒ BorderOptions
constructor
Initialize a BorderOptions.
-
#to_hash ⇒ Object
Convert to hash.
-
#update(obj) ⇒ BorderOptions
Set all accessors with hash attributes.
Constructor Details
#initialize(*args) ⇒ BorderOptions
Initialize a BorderOptions
12 13 14 15 |
# File 'lib/tty/table/border_options.rb', line 12 def initialize(*args) super(*args) self.characters = {} unless characters end |
Instance Attribute Details
#characters ⇒ Object
Returns the value of attribute characters
7 8 9 |
# File 'lib/tty/table/border_options.rb', line 7 def characters @characters end |
#separator ⇒ Object
Returns the value of attribute separator
7 8 9 |
# File 'lib/tty/table/border_options.rb', line 7 def separator @separator end |
#style ⇒ Object
Returns the value of attribute style
7 8 9 |
# File 'lib/tty/table/border_options.rb', line 7 def style @style end |
Class Method Details
.from(value) ⇒ Object
Create options instance from hash
20 21 22 |
# File 'lib/tty/table/border_options.rb', line 20 def self.from(value) value ? new.update(value) : new end |
Instance Method Details
#to_hash ⇒ Object
Convert to hash
41 42 43 44 45 46 47 48 |
# File 'lib/tty/table/border_options.rb', line 41 def to_hash hash = {} members.each do |key| value = send(key) hash[key.to_sym] = value if value end hash end |
#update(obj) ⇒ BorderOptions
Set all accessors with hash attributes
31 32 33 34 35 36 |
# File 'lib/tty/table/border_options.rb', line 31 def update(obj) obj.each_pair do |key, value| self.send("#{key}=", value) end self end |