Class: TokyoMetro::Modules::Db::Select::OperationDay

Inherits:
Object
  • Object
show all
Defined in:
lib/tokyo_metro/modules/db/select/operation_day.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datetime) ⇒ OperationDay

Returns a new instance of OperationDay.



3
4
5
# File 'lib/tokyo_metro/modules/db/select/operation_day.rb', line 3

def initialize( datetime )
  @time = datetime
end

Class Method Details

.process(datetime) ⇒ Object



24
25
26
# File 'lib/tokyo_metro/modules/db/select/operation_day.rb', line 24

def self.process( datetime )
  self.new( datetime ).process
end

Instance Method Details

#holiday?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/tokyo_metro/modules/db/select/operation_day.rb', line 11

def holiday?
  ::HolidayJapan.check( ::Date.new( @time.year , @time.month , @time.day ) )
end

#processObject



15
16
17
18
19
20
21
22
# File 'lib/tokyo_metro/modules/db/select/operation_day.rb', line 15

def process
  if saturday_or_sunday? or holiday?
    ::OperationDay.find_by( same_as: "custom:OperationDay:SaturdayHoliday" )
    # ::OperationDay.find_by( same_as: "custom:OperationDay:SaturdaySundayHoliday" )
  else
    ::OperationDay.find_by( same_as: "custom:OperationDay:Weekday" )
  end
end

#saturday_or_sunday?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/tokyo_metro/modules/db/select/operation_day.rb', line 7

def saturday_or_sunday?
  @time.saturday? or @time.sunday?
end