Class: TokyoMetro::App::Renderer::RealTimeInfos::EachRailwayLine

Inherits:
Factory::Decorate::MetaClass show all
Defined in:
lib/tokyo_metro/app/renderer/real_time_infos/each_railway_line.rb

Constant Summary collapse

TRAIN_OPERATION_STATUS_FOR_TEST =
::YAML.load_file( "#{ ::TokyoMetro::DICTIONARY_DIR }/view/train_operation_status_for_test.yaml" )

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, railway_line, http_client, test_mode) ⇒ EachRailwayLine

Returns a new instance of EachRailwayLine.



5
6
7
8
9
10
11
# File 'lib/tokyo_metro/app/renderer/real_time_infos/each_railway_line.rb', line 5

def initialize( request , railway_line , http_client , test_mode )
  super( request )
  @railway_line = railway_line
  get_train_operation_info( http_client , test_mode )
  get_train_location_infos( http_client , test_mode )
  set_max_delay
end

Instance Attribute Details

#railway_lineObject (readonly)

Returns the value of attribute railway_line.



13
14
15
# File 'lib/tokyo_metro/app/renderer/real_time_infos/each_railway_line.rb', line 13

def railway_line
  @railway_line
end

#train_location_infosObject (readonly)

Returns the value of attribute train_location_infos.



15
16
17
# File 'lib/tokyo_metro/app/renderer/real_time_infos/each_railway_line.rb', line 15

def train_location_infos
  @train_location_infos
end

#train_operation_infoObject (readonly)

Returns the value of attribute train_operation_info.



14
15
16
# File 'lib/tokyo_metro/app/renderer/real_time_infos/each_railway_line.rb', line 14

def train_operation_info
  @train_operation_info
end

Instance Method Details

#render_train_location_infosObject



21
22
23
24
25
# File 'lib/tokyo_metro/app/renderer/real_time_infos/each_railway_line.rb', line 21

def render_train_location_infos
  if @train_location_infos.present?
    @train_location_infos.decorate( request , @railway_line ).render
  end
end

#render_train_operation_info(controller) ⇒ Object



17
18
19
# File 'lib/tokyo_metro/app/renderer/real_time_infos/each_railway_line.rb', line 17

def render_train_operation_info( controller )
  @train_operation_info.decorate( request , @railway_line , @max_delay , controller , no_train? ).render
end

#update_train_operation_text_in_dbObject



27
28
29
30
31
# File 'lib/tokyo_metro/app/renderer/real_time_infos/each_railway_line.rb', line 27

def update_train_operation_text_in_db
  if @train_operation_info.instance_of?( ::TokyoMetro::Api::TrainOperation::Info )
    @train_operation_info.update_train_operation_text_in_db
  end
end