Class: Writeexcel::Worksheet::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/writeexcel/comments.rb

Direct Known Subclasses

Comments

Instance Method Summary collapse

Constructor Details

#initializeCollection

Returns a new instance of Collection


7
8
9
# File 'lib/writeexcel/comments.rb', line 7

def initialize
  @items = {}
end

Instance Method Details

#<<(item) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/writeexcel/comments.rb', line 11

def <<(item)
  if @items[item.row]
    @items[item.row][item.col] = item
  else
    @items[item.row] = { item.col => item }
  end
end

#arrayObject


19
20
21
22
23
24
25
26
27
28
29
# File 'lib/writeexcel/comments.rb', line 19

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