Class: Timely::Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/timely/cell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(report, column, row) ⇒ Cell

Returns a new instance of Cell.



7
8
9
10
11
# File 'lib/timely/cell.rb', line 7

def initialize(report, column, row)
  self.report = report
  self.column = column
  self.row    = row
end

Instance Attribute Details

#columnObject

Returns the value of attribute column.



5
6
7
# File 'lib/timely/cell.rb', line 5

def column
  @column
end

#reportObject

Returns the value of attribute report.



5
6
7
# File 'lib/timely/cell.rb', line 5

def report
  @report
end

#rowObject

Returns the value of attribute row.



5
6
7
# File 'lib/timely/cell.rb', line 5

def row
  @row
end

Instance Method Details

#cache_keyObject



37
38
39
# File 'lib/timely/cell.rb', line 37

def cache_key
  @cache_key ||= [report.cache_key, row.cache_key, column.cache_key].join(cache_sep)
end

#cacheable?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/timely/cell.rb', line 33

def cacheable?
  row.cacheable? && column.cacheable?
end

#column_keyObject



17
18
19
# File 'lib/timely/cell.rb', line 17

def column_key
  column.to_i
end

#column_titleObject



21
22
23
# File 'lib/timely/cell.rb', line 21

def column_title
  column.title
end

#row_titleObject



25
26
27
# File 'lib/timely/cell.rb', line 25

def row_title
  row.title
end

#to_sObject



13
14
15
# File 'lib/timely/cell.rb', line 13

def to_s
  "#<#{self.class.name} row: \"#{row.title}\", starts_at: #{column.starts_at}, ends_at: #{column.ends_at}>"
end

#valueObject



29
30
31
# File 'lib/timely/cell.rb', line 29

def value
  @value ||= cacheable? ? value_with_caching : value_without_caching
end