Class: Chinese::Holidays::Days
- Inherits:
-
Object
- Object
- Chinese::Holidays::Days
- Defined in:
- lib/chinese/holidays/days.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#range ⇒ Object
readonly
Returns the value of attribute range.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #days ⇒ Object
- #holiday? ⇒ Boolean
-
#initialize(name, range, type) ⇒ Days
constructor
A new instance of Days.
- #workingday? ⇒ Boolean
Constructor Details
#initialize(name, range, type) ⇒ Days
Returns a new instance of Days.
7 8 9 10 11 |
# File 'lib/chinese/holidays/days.rb', line 7 def initialize(name, range, type) @name = name @range = range @type = type end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/chinese/holidays/days.rb', line 5 def name @name end |
#range ⇒ Object (readonly)
Returns the value of attribute range.
5 6 7 |
# File 'lib/chinese/holidays/days.rb', line 5 def range @range end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/chinese/holidays/days.rb', line 5 def type @type end |
Instance Method Details
#days ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/chinese/holidays/days.rb', line 21 def days if @range.size == 1 [Date.strptime(@range[0], '%F')] elsif @range.size == 2 (Date.strptime(@range[0], '%F')..Date.strptime(@range[1], '%F')).to_a end end |
#holiday? ⇒ Boolean
13 14 15 |
# File 'lib/chinese/holidays/days.rb', line 13 def holiday? @type == 'holiday' end |
#workingday? ⇒ Boolean
17 18 19 |
# File 'lib/chinese/holidays/days.rb', line 17 def workingday? @type == 'workingday' end |