Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Current week:
- # Week.new
- # Firt week of the year:
- # Week.new(1)
- # First week of 2006 year
- # Week.new(2006, 1)
- class Week
- attr_reader :starts_at, :ends_at
- def initialize(*args)
- if args.size == 0
- year, week = Date.today.year, Date.today.cweek
- elsif args.size == 1
- year, week = Date.today.year, args[0]
- elsif args.size == 2
- year, week = args
- else
- raise ArgumentError, 'wrong number of arguments (0, 1 or 2)'
- end
- @starts_at = Date.commercial(year, week, 1)
- @ends_at = @starts_at + 6
- end
- def to_s
- "#{@starts_at.day} - #{@ends_at.day}"
- end
- def self.all_of_month(month)
- []
- end
- end
Add Comment
Please, Sign In to add comment