Module: Domodoro::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/domodoro/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#soundObject

Returns the value of attribute sound.



6
7
8
# File 'lib/domodoro/config.rb', line 6

def sound
  @sound
end

#visualObject

Returns the value of attribute visual.



6
7
8
# File 'lib/domodoro/config.rb', line 6

def visual
  @visual
end

Instance Method Details

#get_server_configurationObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/domodoro/config.rb', line 21

def get_server_configuration
  config = OpenStruct.new

  if File.exist?(File.expand_path('~/.domodororc'))
    file = YAML.load(File.read(File.expand_path('~/.domodororc')))['server']

    config.pomodoro_duration = file['pomodoro_duration']
    config.pomodoro_break    = file['pomodoro_break']
    config.long_break_after  = file['long_break_after']

    config.day_start         = Timepoint.new(file['day_start'])
    config.day_end           = Timepoint.new(file['day_end'])

    config.lunch_time        = Timepoint.new(file['lunch_time'])
    config.lunch_duration    = file['lunch_duration']
  end

  config.pomodoro_duration ||= 25
  config.pomodoro_break    ||= 5
  config.long_break_after  ||= 4

  config.day_start         ||= Timepoint.new('08:30')
  config.day_end           ||= Timepoint.new('16:30')

  config.lunch_time        ||= Timepoint.new('13:00')
  config.lunch_duration    ||= 30

  config
end

#load_client_configurationObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/domodoro/config.rb', line 9

def load_client_configuration
  if File.exist?(File.expand_path('~/.domodororc'))
    file = YAML.load(File.read(File.expand_path('~/.domodororc')))

    self.visual = file['visual']
    self.sound  = file['sound']
  else
    self.visual = true
    self.sound  = true
  end
end