Class: TTY::Table::BorderOptions Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A class that represents table border options

Used internally by Border to manage options such as style

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ BorderOptions

Initialize a BorderOptions



14
15
16
17
# File 'lib/tty/table/border_options.rb', line 14

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



10
11
12
# File 'lib/tty/table/border_options.rb', line 10

def characters
  @characters
end

#separatorObject

Returns the value of attribute separator

Returns:

  • (Object)

    the current value of separator



10
11
12
# File 'lib/tty/table/border_options.rb', line 10

def separator
  @separator
end

#styleObject

Returns the value of attribute style

Returns:

  • (Object)

    the current value of style



10
11
12
# File 'lib/tty/table/border_options.rb', line 10

def style
  @style
end

Class Method Details

.from(value) ⇒ Object

Create options instance from hash



22
23
24
# File 'lib/tty/table/border_options.rb', line 22

def self.from(value)
  value ? new.update(value) : new
end

Instance Method Details

#to_hashObject

Convert to hash



43
44
45
46
47
48
49
50
# File 'lib/tty/table/border_options.rb', line 43

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:



33
34
35
36
37
38
# File 'lib/tty/table/border_options.rb', line 33

def update(obj)
  obj.each_pair do |key, value|
    send("#{key}=", value)
  end
  self
end