Guest User

Untitled

a guest
May 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. # Current week:
  2. # Week.new
  3. # Firt week of the year:
  4. # Week.new(1)
  5. # First week of 2006 year
  6. # Week.new(2006, 1)
  7. class Week
  8. attr_reader :starts_at, :ends_at
  9.  
  10. def initialize(*args)
  11. if args.size == 0
  12. year, week = Date.today.year, Date.today.cweek
  13. elsif args.size == 1
  14. year, week = Date.today.year, args[0]
  15. elsif args.size == 2
  16. year, week = args
  17. else
  18. raise ArgumentError, 'wrong number of arguments (0, 1 or 2)'
  19. end
  20.  
  21. @starts_at = Date.commercial(year, week, 1)
  22. @ends_at = @starts_at + 6
  23. end
  24.  
  25. def to_s
  26. "#{@starts_at.day} - #{@ends_at.day}"
  27. end
  28.  
  29. def self.all_of_month(month)
  30. []
  31. end
  32. end
Add Comment
Please, Sign In to add comment