Class: TTY::Table::BorderOptions

Inherits:
Struct
  • Object
show all
Defined in:
lib/tty/table/border_options.rb

Overview

A class that represents table border options

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#charactersObject

Returns the value of attribute characters

Returns:

  • (Object)

    the current value of characters



7
8
9
# File 'lib/tty/table/border_options.rb', line 7

def characters
  @characters
end

#separatorObject

Returns the value of attribute separator

Returns:

  • (Object)

    the current value of separator



7
8
9
# File 'lib/tty/table/border_options.rb', line 7

def separator
  @separator
end

#styleObject

Returns the value of attribute style

Returns:

  • (Object)

    the current value of 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_hashObject

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

Parameters:

Returns:



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