Class: ODDB::LogGroup

Inherits:
Object show all
Includes:
Persistence
Defined in:
src/util/loggroup.rb,
test/test_util/loggroup.rb

Constant Summary

Constants included from Persistence

ODBA_PREDEFINE_SERIALIZABLE

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from PersistenceMethods

#checkout, #data_origin, #data_origins, #diff, #init, #nil_if_empty, #parent, #pointer_descr, #structural_ancestors, #undiffable?, #update_values

Constructor Details

- (LogGroup) initialize(key)

A new instance of LogGroup



12
13
14
15
# File 'src/util/loggroup.rb', line 12

def initialize(key)
  @key = key
  @logs = {}
end

Instance Attribute Details

- (Object) key (readonly)

Returns the value of attribute key



11
12
13
# File 'src/util/loggroup.rb', line 11

def key
  @key
end

- (Object) logs

Returns the value of attribute logs



11
12
13
# File 'src/util/loggroup.rb', line 11

def logs
  @logs
end

Instance Method Details

- (Object) create_log(date)



16
17
18
# File 'src/util/loggroup.rb', line 16

def create_log(date)
  @logs[date] = Log.new(date)
end

- (Object) latest



19
20
21
# File 'src/util/loggroup.rb', line 19

def latest
  @logs[newest_date]
end

- (Object) log(date)



22
23
24
# File 'src/util/loggroup.rb', line 22

def log(date)
  @logs[date]
end

- (Object) months(year)



25
26
27
28
29
30
31
# File 'src/util/loggroup.rb', line 25

def months(year)
  @logs.keys.select { |date| 
    date.year == year 
  }.collect { |date| 
    date.month 
  }.sort
end

- (Object) newest_date



32
33
34
# File 'src/util/loggroup.rb', line 32

def newest_date
  @logs.keys.max
end

- (Object) years



35
36
37
# File 'src/util/loggroup.rb', line 35

def years
  @logs.keys.collect { |date| date.year }.uniq.sort
end