Exception: RockBooks::DateRangeError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/rock_books/errors/date_range_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date, start_date, end_date, extra_string = nil) ⇒ DateRangeError

Returns a new instance of DateRangeError.



6
7
8
9
10
11
# File 'lib/rock_books/errors/date_range_error.rb', line 6

def initialize(date, start_date, end_date, extra_string = nil)
  @date = date
  @start_date = start_date
  @end_date = end_date
  @extra_string = extra_string
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



4
5
6
# File 'lib/rock_books/errors/date_range_error.rb', line 4

def date
  @date
end

#end_dateObject (readonly)

Returns the value of attribute end_date.



4
5
6
# File 'lib/rock_books/errors/date_range_error.rb', line 4

def end_date
  @end_date
end

#extra_stringObject (readonly)

Returns the value of attribute extra_string.



4
5
6
# File 'lib/rock_books/errors/date_range_error.rb', line 4

def extra_string
  @extra_string
end

#start_dateObject (readonly)

Returns the value of attribute start_date.



4
5
6
# File 'lib/rock_books/errors/date_range_error.rb', line 4

def start_date
  @start_date
end

Instance Method Details

#to_sObject



13
14
15
16
17
18
# File 'lib/rock_books/errors/date_range_error.rb', line 13

def to_s
  s = "#{date} is not within this data set's period of #{start_date} to #{end_date}"
  s << " (#{extra_string})" if extra_string
  s << '.'
  s
end