Class: Charty::ArrayLayout

Inherits:
Object
  • Object
show all
Defined in:
lib/charty/layout.rb

Instance Method Summary collapse

Constructor Details

#initialize(direction = :horizontal) ⇒ ArrayLayout


38
39
40
41
# File 'lib/charty/layout.rb', line 38

def initialize(direction=:horizontal)
  @array = []
  @direction = direction
end

Instance Method Details

#<<(content) ⇒ Object


43
44
45
# File 'lib/charty/layout.rb', line 43

def <<(content)
  @array << content
end

#num_colsObject


51
52
53
# File 'lib/charty/layout.rb', line 51

def num_cols
  @direction == :vertical ? 1 : @array.count
end

#num_rowsObject


47
48
49
# File 'lib/charty/layout.rb', line 47

def num_rows
  @direction == :horizontal ? 1 : @array.count
end

#rowsObject


55
56
57
# File 'lib/charty/layout.rb', line 55

def rows
  [@array]
end