Class: PunchTime::Configuration

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/punch_time/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|raw| ... } ⇒ Configuration

Returns a new instance of Configuration.

Yields:

Raises:

  • (ArgumentError)


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

def initialize
  self.raw = Raw.new

  yield raw if block_given?

  self.shift_in_time ||= raw.shift_in_time
  self.shift_out_time ||= raw.shift_out_time
  self.night ||= raw.night
  self.breaks ||= raw.breaks
  self.offset ||= raw.offset

  raise ArgumentError, errors.messages unless valid?

  raw.freeze
end

Instance Attribute Details

#breaksObject

Returns the value of attribute breaks.



15
16
17
# File 'lib/punch_time/configuration.rb', line 15

def breaks
  @breaks
end

#nightObject

Returns the value of attribute night.



14
15
16
# File 'lib/punch_time/configuration.rb', line 14

def night
  @night
end

#offsetObject

Returns the value of attribute offset.



16
17
18
# File 'lib/punch_time/configuration.rb', line 16

def offset
  @offset
end

#rawObject

Returns the value of attribute raw.



11
12
13
# File 'lib/punch_time/configuration.rb', line 11

def raw
  @raw
end

#shift_in_timeObject

Returns the value of attribute shift_in_time.



12
13
14
# File 'lib/punch_time/configuration.rb', line 12

def shift_in_time
  @shift_in_time
end

#shift_out_timeObject

Returns the value of attribute shift_out_time.



13
14
15
# File 'lib/punch_time/configuration.rb', line 13

def shift_out_time
  @shift_out_time
end