Class: Beggar::CurrentMonth

Inherits:
Object
  • Object
show all
Defined in:
lib/beggar/current_month.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) first_day



4
5
6
# File 'lib/beggar/current_month.rb', line 4

def first_day
  Date.new(Date.today.year, Date.today.month, 1)
end

+ (Object) last_day



8
9
10
# File 'lib/beggar/current_month.rb', line 8

def last_day
  first_day.next_month - 1
end

+ (Object) to_s



20
21
22
# File 'lib/beggar/current_month.rb', line 20

def to_s
  %[#{(working_days_up_today.to_f / working_days * 100).round}%]
end

+ (Object) working_days(last_day = last_day)



12
13
14
# File 'lib/beggar/current_month.rb', line 12

def working_days(last_day = last_day)
  (first_day..last_day).reject { |d| [0,6].include? d.wday }.size
end

+ (Object) working_days_up_today



16
17
18
# File 'lib/beggar/current_month.rb', line 16

def working_days_up_today
  working_days(Date.today)
end