Class: PagSeguro::DayOfYear
- Inherits:
-
Object
- Object
- PagSeguro::DayOfYear
- Includes:
- Comparable
- Defined in:
- lib/pag_seguro/day_of_year.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
Returns the value of attribute day.
-
#month ⇒ Object
Returns the value of attribute month.
Instance Method Summary collapse
- #<=>(other_day_of_the_year) ⇒ Object
-
#initialize(options = {}) ⇒ DayOfYear
constructor
A new instance of DayOfYear.
- #to_s ⇒ Object
-
#valid? ⇒ Boolean
very simple date validation, just to smoke test possible errors of switching day with month.
Constructor Details
#initialize(options = {}) ⇒ DayOfYear
Returns a new instance of DayOfYear.
14 15 16 17 |
# File 'lib/pag_seguro/day_of_year.rb', line 14 def initialize( = {}) @day = [:day] @month = [:month] end |
Instance Attribute Details
#day ⇒ Object
Returns the value of attribute day.
12 13 14 |
# File 'lib/pag_seguro/day_of_year.rb', line 12 def day @day end |
#month ⇒ Object
Returns the value of attribute month.
12 13 14 |
# File 'lib/pag_seguro/day_of_year.rb', line 12 def month @month end |
Instance Method Details
#<=>(other_day_of_the_year) ⇒ Object
30 31 32 33 34 |
# File 'lib/pag_seguro/day_of_year.rb', line 30 def <=>(other_day_of_the_year) return 1 if @month > other_day_of_the_year.month return -1 if @month < other_day_of_the_year.month @day <=> other_day_of_the_year.day end |
#to_s ⇒ Object
19 20 21 22 |
# File 'lib/pag_seguro/day_of_year.rb', line 19 def to_s raise Error::InvalidDayOfYear.new(self) unless valid? "#{"%02d" % @month}-#{"%02d" % @day}" end |
#valid? ⇒ Boolean
very simple date validation, just to smoke test possible errors of switching day with month
26 27 28 |
# File 'lib/pag_seguro/day_of_year.rb', line 26 def valid? @day < 31 && @month < 12 end |