Class: Tabl::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/tabl/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values_override = nil, &block) ⇒ Definition

Returns a new instance of Definition.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tabl/definition.rb', line 11

def initialize(values_override = nil, &block)
  @columns = []
  @labels = {}
  @values = {}
  @format = {}
  @values_override = values_override
  @default_format = lambda { |v| v }
  @default_value = nil
  configure(&block)
  format = Hash.new { Format.new }
end

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



3
4
5
# File 'lib/tabl/definition.rb', line 3

def columns
  @columns
end

#default_formatObject

Returns the value of attribute default_format.



8
9
10
# File 'lib/tabl/definition.rb', line 8

def default_format
  @default_format
end

#default_valueObject

Returns the value of attribute default_value.



9
10
11
# File 'lib/tabl/definition.rb', line 9

def default_value
  @default_value
end

#formatObject (readonly)

Returns the value of attribute format.



7
8
9
# File 'lib/tabl/definition.rb', line 7

def format
  @format
end

#labelsObject (readonly)

Returns the value of attribute labels.



4
5
6
# File 'lib/tabl/definition.rb', line 4

def labels
  @labels
end

#valuesObject (readonly)

Returns the value of attribute values.



5
6
7
# File 'lib/tabl/definition.rb', line 5

def values
  @values
end

Instance Method Details

#cloneObject



35
36
37
38
39
40
41
42
# File 'lib/tabl/definition.rb', line 35

def clone
  other = super
  other.instance_variable_set(:@columns, @columns.clone)
  other.instance_variable_set(:@labels, @labels.clone)
  other.instance_variable_set(:@values, @values.clone)
  other.instance_variable_set(:@format, @format.clone)
  other
end

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



23
24
25
# File 'lib/tabl/definition.rb', line 23

def configure(&block)
  yield(self) if block_given?
end