class TimeUntilBreak

Constants

VERSION

Attributes

break_time[R]
break_time_end[R]

Public Class Methods

new(break_time="16:45", break_time_end="17:00") click to toggle source
# File lib/time_until_break.rb, line 8
def initialize (break_time="16:45", break_time_end="17:00")
  @break_time = Time.parse(break_time)
  @break_time_end = Time.parse(break_time_end)
end

Public Instance Methods

break_now() click to toggle source
# File lib/time_until_break.rb, line 44
def break_now
  say_something("Get your shizzle on, it's break time right now. All around the world.")
end
break_right_now?() click to toggle source
# File lib/time_until_break.rb, line 40
def break_right_now?
  current_time > @break_time && current_time < @break_time_end
end
check_time() click to toggle source
# File lib/time_until_break.rb, line 17
def check_time
  break_right_now? ? break_now : time_until_break
end
current_time() click to toggle source
# File lib/time_until_break.rb, line 48
def current_time
  Time.now
end
has_break_been?() click to toggle source
# File lib/time_until_break.rb, line 32
def has_break_been?
  current_time > @break_time_end
end
is_a_weekday() click to toggle source
# File lib/time_until_break.rb, line 13
def is_a_weekday
  has_break_been? ? missed_break : check_time
end
is_a_weekend() click to toggle source
# File lib/time_until_break.rb, line 21
def is_a_weekend
  say_something("It's the weekend you silly billy.")
end
is_it_the_weekend?() click to toggle source
# File lib/time_until_break.rb, line 56
def is_it_the_weekend?
  ["Saturday", "Sunday"].include?(current_time.strftime("%A"))
end
missed_break() click to toggle source
# File lib/time_until_break.rb, line 36
def missed_break
  say_something("Sorry you missed the Mandatory Break.")
end
run_me() click to toggle source
# File lib/time_until_break.rb, line 60
def run_me
  is_it_the_weekend? ? is_a_weekend : is_a_weekday
end
say_something(string) click to toggle source
# File lib/time_until_break.rb, line 52
def say_something(string)
  %x(say "#{string}")
end
time_until_break() click to toggle source
# File lib/time_until_break.rb, line 25
def time_until_break
  seconds = @break_time.to_i - current_time.to_i
  hours = (seconds/(60*60))
  minutes = ((seconds - (hours*60*60))/60)
  say_something("#{hours} hours, #{minutes} minutes until the Mandatory Break.")
end