Class: IfcDate
- Inherits:
-
Object
- Object
- IfcDate
- Extended by:
- IfcDateClassMethods
- Defined in:
- lib/ifc_date.rb,
lib/ifc_date/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- DAYNAMES =
Date::DAYNAMES + ['Starday']
- ABBR_DAYNAMES =
Date::ABBR_DAYNAMES + ['Sta']
- MONTHNAMES =
Date::MONTHNAMES.dup.insert(6, 'Sol')
- ABBR_MONTHNAMES =
Date::ABBR_MONTHNAMES.dup.insert(6, 'Sol')
- VERSION =
"0.1.1"
Instance Attribute Summary collapse
-
#day_of_year ⇒ Object
(also: #yday)
readonly
Returns the value of attribute day_of_year.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #abbr_day_name ⇒ Object
- #abbr_month_name ⇒ Object
- #day_name ⇒ Object
- #day_of_month ⇒ Object (also: #mday)
-
#initialize(day_of_year = nil, year = nil) ⇒ IfcDate
constructor
A new instance of IfcDate.
- #month_name ⇒ Object
-
#month_of_year ⇒ Object
(also: #month)
Return the month in index of the year.
Methods included from IfcDateClassMethods
Constructor Details
#initialize(day_of_year = nil, year = nil) ⇒ IfcDate
Returns a new instance of IfcDate.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ifc_date.rb', line 18 def initialize(day_of_year = nil, year = nil) unless year date = Date.today year = date.year day_of_year ||= date.yday end day_of_year ||= date.yday @day_of_year = day_of_year @year = year end |
Instance Attribute Details
#day_of_year ⇒ Object (readonly) Also known as: yday
Returns the value of attribute day_of_year.
11 12 13 |
# File 'lib/ifc_date.rb', line 11 def day_of_year @day_of_year end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
11 12 13 |
# File 'lib/ifc_date.rb', line 11 def year @year end |
Instance Method Details
#abbr_day_name ⇒ Object
93 94 95 |
# File 'lib/ifc_date.rb', line 93 def abbr_day_name ABBR_DAYNAMES[day_of_week] end |
#abbr_month_name ⇒ Object
101 102 103 |
# File 'lib/ifc_date.rb', line 101 def abbr_month_name ABBR_MONTHNAMES[month_of_year] end |
#day_name ⇒ Object
89 90 91 |
# File 'lib/ifc_date.rb', line 89 def day_name DAYNAMES[day_of_week] end |
#day_of_month ⇒ Object Also known as: mday
74 75 76 77 |
# File 'lib/ifc_date.rb', line 74 def day_of_month return 29 if starday? day_of_year_divmod_twenty_eight[1] + 1 end |
#month_name ⇒ Object
97 98 99 |
# File 'lib/ifc_date.rb', line 97 def month_name MONTHNAMES[month_of_year] end |
#month_of_year ⇒ Object Also known as: month
Return the month in index of the year. NOTE Januari will be 1, so different indexing thant the wday
82 83 84 85 86 |
# File 'lib/ifc_date.rb', line 82 def month_of_year return 13 if day_of_year > 364 # prevent 14 return 6 if leap_year? && day_of_year == 169 day_of_year_divmod_twenty_eight[0] + 1 end |