class CalcWorkingHours::TimeCard

Public Class Methods

new(card_id, id) click to toggle source
# File lib/calc_working_hours/time_card.rb, line 6
def initialize(card_id, id)
  @time_card_rows = []
  @card_id = card_id
  @id = id
  self
end

Public Instance Methods

add_row(time_card_rows_obj) click to toggle source
# File lib/calc_working_hours/time_card.rb, line 13
def add_row(time_card_rows_obj)
  @time_card_rows << time_card_rows_obj
  self
end
total_night_time() click to toggle source
# File lib/calc_working_hours/time_card.rb, line 47
def total_night_time 
  self.total_working_hours_in_range("22:00", "29:00")
end
total_over_time() click to toggle source
# File lib/calc_working_hours/time_card.rb, line 26
def total_over_time
  array_of_over_time = []
  @time_card_rows.each do |row|
    array_of_over_time << row.over_time.time_string
  end
  return WorkingHours.new("0:00").add_array_time(array_of_over_time).time_string      
end
total_working_hours() click to toggle source
# File lib/calc_working_hours/time_card.rb, line 18
def total_working_hours
  array_of_working_hours = []
  @time_card_rows.each do |row|
    array_of_working_hours << row.working_hours.time_string
  end
  return WorkingHours.new("0:00").add_array_time(array_of_working_hours).time_string
end
total_working_hours_in_range(start_range, end_range) click to toggle source
# File lib/calc_working_hours/time_card.rb, line 34
def total_working_hours_in_range(start_range, end_range)
  array_of_working_hours_in_range = []
  if start_range == true && end_range == true
    unless CalcHelper.valid_time_format?(start_range) || CalcHelper.valid_time_format?(end_range)
      raise "invalid time format (TimeCard total_working_hours)"
    end
  end
  @time_card_rows.each do |row|
    array_of_working_hours_in_range << row.working_hours_in_range(start_range, end_range)
  end
  return WorkingHours.new("0:00").add_array_time(array_of_working_hours_in_range).time_string
end