Class: Google::Visualization::DataRow

Inherits:
DataElement show all
Defined in:
lib/google_visualization/data_row.rb

Overview

DataRow

Description

Represents a row of data in a DataTable.

Instance Method Summary collapse

Methods inherited from DataElement

#custom_properties, #custom_properties_count, #custom_property, #store_custom_properties, #store_custom_property

Constructor Details

#initialize(cells = []) ⇒ DataRow

Creates a new row.



16
17
18
19
20
21
# File 'lib/google_visualization/data_row.rb', line 16

def initialize(cells=[])
  super()
  @closed = false
  @cells = []
  add_cells(cells) unless (cells.nil? or cells.empty?)
end

Instance Method Details

#add_cell(obj) ⇒ Object

Adds a single object to the end of the row and returns self.

Raises:

  • (StandardError)


47
48
49
50
51
52
# File 'lib/google_visualization/data_row.rb', line 47

def add_cell(obj)
  raise(StandardError, "can't modify closed row") if @closed
  obj = DataCell.new(obj) unless obj.is_a?(DataCell)
  @cells << obj
  self
end

#add_cells(list) ⇒ Object

Adds multiple objects to the end of the row and returns self.



57
58
59
60
# File 'lib/google_visualization/data_row.rb', line 57

def add_cells(list)
  list.each { |obj| add_cell(obj) }
  self
end

#cell(index) ⇒ Object

Returns the cell at index.



33
34
35
# File 'lib/google_visualization/data_row.rb', line 33

def cell(index)
  @cells[index]
end

#cellsObject

Returns a enumerable of all cells.



40
41
42
# File 'lib/google_visualization/data_row.rb', line 40

def cells
  @cells.to_enum
end

#cells_countObject

Returns the number of cells.



26
27
28
# File 'lib/google_visualization/data_row.rb', line 26

def cells_count
  @cells.size
end

#closeObject

Prevents new cells from being added.



65
66
67
# File 'lib/google_visualization/data_row.rb', line 65

def close
  @closed = true
end

#closed?Boolean

Returns true if closed.

Returns:

  • (Boolean)


72
73
74
# File 'lib/google_visualization/data_row.rb', line 72

def closed?
  @closed
end