Class: Writeexcel::Worksheet::Collection
- Inherits:
-
Object
- Object
- Writeexcel::Worksheet::Collection
- Defined in:
- lib/writeexcel/comments.rb
Direct Known Subclasses
Instance Method Summary collapse
- #<<(item) ⇒ Object
- #array ⇒ Object
-
#initialize ⇒ Collection
constructor
A new instance of Collection.
Constructor Details
#initialize ⇒ Collection
Returns a new instance of Collection.
7 8 9 10 |
# File 'lib/writeexcel/comments.rb', line 7 def initialize @items = {} @array = nil end |
Instance Method Details
#<<(item) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/writeexcel/comments.rb', line 12 def <<(item) if @items[item.row] @items[item.row][item.col] = item else @items[item.row] = { item.col => item } end end |
#array ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/writeexcel/comments.rb', line 20 def array return @array if @array @array = [] @items.keys.sort.each do |row| @items[row].keys.sort.each do |col| @array << @items[row][col] end end @array end |