module NHKProgram::Helper
Public Instance Methods
parse_area(area)
click to toggle source
@return [Area] @raise [Error]
# File lib/nhk_program/helper.rb, line 13 def parse_area(area) Area.find_by_id(area) or Area.find_by_name(area) or raise Error, 'Area not found' end
parse_date(date)
click to toggle source
@return [Date] @raise [Error]
# File lib/nhk_program/helper.rb, line 37 def parse_date(date) case date when Date date when Time date.to_date when String Date.parse(date) when Symbol case date when :today Date.today when :tomorrow Date.today + 1 else raise NHKProgram::Error, 'Invalid date' end else raise NHKProgram::Error, 'Invalid date' end end
parse_genre(genre)
click to toggle source
@return [Genre] @raise [Error]
# File lib/nhk_program/helper.rb, line 29 def parse_genre(genre) Genre.find_by_id(genre) or Genre.find_by_name(genre) or raise Error, 'Genre not found' end
parse_service(service)
click to toggle source
@return [Service] @raise [Error]
# File lib/nhk_program/helper.rb, line 21 def parse_service(service) Service.find_by_id(service) or Service.find_by_name(service) or raise Error, 'Service not found' end