Class: Tablemaker::Frame

Inherits:
Object
  • Object
show all
Defined in:
lib/tablemaker/frame.rb

Direct Known Subclasses

Cell, Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, idx) ⇒ Frame

Returns a new instance of Frame.



5
6
7
8
# File 'lib/tablemaker/frame.rb', line 5

def initialize(parent, idx)
  @parent = parent
  @index = idx
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



4
5
6
# File 'lib/tablemaker/frame.rb', line 4

def parent
  @parent
end

Instance Method Details

#dimensionsObject



13
14
15
# File 'lib/tablemaker/frame.rb', line 13

def dimensions
  [columns, rows]
end

#last?Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/tablemaker/frame.rb', line 9

def last?
  return nil unless @parent
  @index == @parent.items.length-1
end

#real_colsObject



25
26
27
28
29
30
31
32
33
# File 'lib/tablemaker/frame.rb', line 25

def real_cols
  return columns unless @parent
  if @parent.is_a?(Column)
    @parent.real_cols
  else
    return columns unless last?
    return columns + @parent.real_cols - @parent.columns
  end
end

#real_dimensionsObject



34
35
36
# File 'lib/tablemaker/frame.rb', line 34

def real_dimensions
  [real_cols, real_rows]
end

#real_rowsObject



16
17
18
19
20
21
22
23
24
# File 'lib/tablemaker/frame.rb', line 16

def real_rows
  return rows unless @parent
  if @parent.is_a?(Column)
    return rows unless last?
    return rows + @parent.real_rows - @parent.rows
  else
    @parent.real_rows
  end
end