lib/uk_financial_year.rb in fyuk-0.1.1 vs lib/uk_financial_year.rb in fyuk-0.2.0
- old
+ new
@@ -11,10 +11,18 @@
def initialize date
start_date = start_date date
@range = start_date...start_date.next_year
end
+ # returns string representation of the financial year in the form '2000/01'.
+ # This is the form HMRC use.
+ # @return [String] representation in the form of the first year as four
+ # digits, a '/', then the last year as two digits
+ def to_s
+ "#{self.first_day.year}/#{self.last_day.year.to_s[-2..-1]}"
+ end
+
# creates a new UkFinancialYear from a string in the form '2000/01'
# @param [String] s the two years of the financial year in the form
# of the first year as four digits, a '/', then the last year as
# two digits
# @raise [RuntimeError] if the string cannot be parsed to a financial year
@@ -61,14 +69,11 @@
# @return [UkFinancialYear] the previous financial year
def previous
UkFinancialYear.new self.first_day.prev_year
end
- # returns string representation of the financial year in the form '2000/01'
- # @return [String] representation in the form of the first year as four
- # digits, a '/', then the last year as two digits
- def to_s
- "#{self.first_day.year}/#{self.last_day.year.to_s[-2..-1]}"
+ def adjacent? other_financial_year
+ self.first_day.next_year == other_financial_year.first_day || self.first_day.prev_year == other_financial_year.first_day
end
# equality method
def ==(other)
self.first_day == other.first_day
\ No newline at end of file