Class: ActivityLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/activity-logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(dir: nil, options: {}, config: nil) ⇒ ActivityLogger

Returns a new instance of ActivityLogger.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/activity-logger.rb', line 22

def initialize(dir: nil, options: {}, config: nil)

  @options = options
  @publish_html = false

  
  if config then
    
    h = SimpleConfig.new(config).to_h
    dir, @urlbase, @edit_url, @css_url, @xsl_path = \
                     %i(dir urlbase edit_url css_url xsl_path).map{|x| h[x]}
    @publish_html = true
  end
  
  Dir.chdir(dir) if dir
end

Instance Method Details

#create(desc = '', time = Time.now, id: id=nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/activity-logger.rb', line 39

def create(desc='', time=Time.now, id: id=nil)

  ddaily = DynarexDaily.new(nil, options: @options)
  
  ddaily.create(time: time.to_s, desc: desc, id: id)
  ddaily.save

  if @publish_html then
    File.write 'index.txt', ddaily.to_s
    save_html() 
  end
  
end