Class: Beggar::CurrentMonth
- Inherits:
-
Object
- Object
- Beggar::CurrentMonth
- Defined in:
- lib/beggar/current_month.rb
Instance Method Summary collapse
- #first_day ⇒ Object
-
#initialize(options = {}) ⇒ CurrentMonth
constructor
A new instance of CurrentMonth.
- #last_day ⇒ Object
- #month ⇒ Object
- #today ⇒ Object
- #workday_hours ⇒ Object
- #workday_hours_until_today ⇒ Object
- #workdays ⇒ Object
- #workdays_progression ⇒ Object
- #workdays_until(date) ⇒ Object
- #workdays_until_today ⇒ Object
- #year ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ CurrentMonth
Returns a new instance of CurrentMonth.
5 6 7 |
# File 'lib/beggar/current_month.rb', line 5 def initialize( = {}) @country = [:country] end |
Instance Method Details
#first_day ⇒ Object
34 35 36 |
# File 'lib/beggar/current_month.rb', line 34 def first_day Date.new(year, month, 1) end |
#last_day ⇒ Object
38 39 40 |
# File 'lib/beggar/current_month.rb', line 38 def last_day first_day.next_month - 1 end |
#month ⇒ Object
46 47 48 |
# File 'lib/beggar/current_month.rb', line 46 def month today.month end |
#today ⇒ Object
50 51 52 |
# File 'lib/beggar/current_month.rb', line 50 def today Date.today end |
#workday_hours ⇒ Object
17 18 19 |
# File 'lib/beggar/current_month.rb', line 17 def workday_hours workdays * 8.0 end |
#workday_hours_until_today ⇒ Object
21 22 23 |
# File 'lib/beggar/current_month.rb', line 21 def workday_hours_until_today workdays_until_today * 8.0 end |
#workdays ⇒ Object
9 10 11 |
# File 'lib/beggar/current_month.rb', line 9 def workdays workdays_until(last_day) end |
#workdays_progression ⇒ Object
25 26 27 |
# File 'lib/beggar/current_month.rb', line 25 def workdays_progression (workdays_until_today * 100.0 / workdays).round end |
#workdays_until(date) ⇒ Object
29 30 31 32 |
# File 'lib/beggar/current_month.rb', line 29 def workdays_until(date) (first_day..date).reject { |d| [0, 6].include?(d.wday) || d.holiday?(@country) }.length end |
#workdays_until_today ⇒ Object
13 14 15 |
# File 'lib/beggar/current_month.rb', line 13 def workdays_until_today workdays_until(today) end |
#year ⇒ Object
42 43 44 |
# File 'lib/beggar/current_month.rb', line 42 def year today.year end |