Class: ColorfulTables::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/colorful_tables/column.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :data_color                 => :light_blue,
  :header_color               => :light_blue,
  :digits_after_decimal_point => 4
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header, data, options = {}) ⇒ Column

Returns a new instance of Column.



15
16
17
18
19
20
# File 'lib/colorful_tables/column.rb', line 15

def initialize(header, data, options = {})
  @header  = header
  @data    = data
  @options = options.reverse_merge!(DEFAULT_OPTIONS)
  @width ||= calculate_width
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



11
12
13
# File 'lib/colorful_tables/column.rb', line 11

def data
  @data
end

#headerObject

Returns the value of attribute header.



11
12
13
# File 'lib/colorful_tables/column.rb', line 11

def header
  @header
end

#optionsObject

Returns the value of attribute options.



11
12
13
# File 'lib/colorful_tables/column.rb', line 11

def options
  @options
end

#widthObject (readonly)

Returns the value of attribute width.



13
14
15
# File 'lib/colorful_tables/column.rb', line 13

def width
  @width
end