Class: LEWT::CalendarTimekeeping

Inherits:
Extension show all
Defined in:
lib/extensions/calendar-timekeeping/calendar-timekeeping.rb

Instance Attribute Summary

Attributes inherited from Extension

#command_name, #customers, #enterprise, #lewt_settings, #lewt_stash, #options

Instance Method Summary collapse

Methods inherited from Extension

#get_matched_customers, #lewt_extensions

Constructor Details

#initializeCalendarTimekeeping

Sets up this extension and registers its options.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/extensions/calendar-timekeeping/calendar-timekeeping.rb', line 28

def initialize
  # set extension options
  options = {
    :calendar => {
      :default => "ical",
      :definition => "The calender extraction method to use, supports 'ical', 'osx' calender extraction. Defaults to ical.",
      :type => String,
    },
    :suppress => {
      :definition => "Suppresses the cost calculation for the specified targets when calulating the hourly rates on extracted calender data.",
      :type => String
    }
  }    
  super({:cmd => "calendar", :options => options})
end

Instance Method Details

#extract(options) ⇒ Object

Extracts data from a given calender source based on what was passed in the options['ext_method'] parameter.

options [Hash]

The options hash passed to this function by the Lewt program.

returns

LEWTBook



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/extensions/calendar-timekeeping/calendar-timekeeping.rb', line 47

def extract( options )
  targetCustomers = self.get_matched_customers( options[:target], options[:suppress] )
  dStart =  options[:start]
  dEnd = options[:end]
  suppressTargets = options[:suppress] == nil ? nil : self.get_matched_customers(options[:suppress])
  if options[:calendar] == "ical"
    extract = CalendarExtractors::ICalExtractor.new( dStart, dEnd, targetCustomers, lewt_settings, suppressTargets )
  elsif options[:calendar] == "osx"
    extract = CalendarExtractors::AppleExtractor.new(dStart, dEnd, targetCustomers, lewt_settings, suppressTargets )
  end
  return extract.data
end