Class: TokyoMetro::App::Renderer::RealTimeInfos::MetaDatum::TrainLocationInfos

Inherits:
MetaClass show all
Defined in:
lib/tokyo_metro/app/renderer/real_time_infos/meta_datum/train_location_infos.rb

Instance Method Summary collapse

Methods inherited from MetaClass

#initialize, #render_dc_date_en, #render_dc_date_ja, #render_next_update_time_en, #render_next_update_time_ja

Constructor Details

This class inherits a constructor from TokyoMetro::App::Renderer::RealTimeInfos::MetaDatum::MetaClass

Instance Method Details

#frequencyObject



3
4
5
# File 'lib/tokyo_metro/app/renderer/real_time_infos/meta_datum/train_location_infos.rb', line 3

def frequency
  @time_infos.map( &:frequency ).sort.uniq
end

#render(include_train_location_infos: false, include_delay: true) ⇒ Object

列車位置情報のメタデータを出力するメソッド



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tokyo_metro/app/renderer/real_time_infos/meta_datum/train_location_infos.rb', line 8

def render( include_train_location_infos: false , include_delay: true )
  raise "Error" unless [ include_delay , include_train_location_infos ].all?( &:boolean? )
  raise "Error" if !( include_delay ) and !( include_train_location_infos )
  h_locals = {
    this: self ,
    include_delay: include_delay ,
    include_train_location_infos: include_train_location_infos
  }

  h.render inline: <<-HAML , type: :haml , locals: h_locals
%li{ class: :train_location_infos }
= this.render_title( include_train_location_infos , include_delay )
= this.render_meta_data
  HAML
end

#render_frequency_enObject



64
65
66
# File 'lib/tokyo_metro/app/renderer/real_time_infos/meta_datum/train_location_infos.rb', line 64

def render_frequency_en
  render_frequency( "Updates at intervals of #{ frequency_to_s } seconds." )
end

#render_frequency_jaObject



60
61
62
# File 'lib/tokyo_metro/app/renderer/real_time_infos/meta_datum/train_location_infos.rb', line 60

def render_frequency_ja
  render_frequency( "#{ frequency_to_s }秒ごとに更新" )
end

#render_meta_dataObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/tokyo_metro/app/renderer/real_time_infos/meta_datum/train_location_infos.rb', line 47

def 
  h.render inline: <<-HAML , type: :haml , locals: h_locals
%ul{ class: :time_infos_of_category }
= this.render_dc_date_ja
= this.render_next_update_time_ja
= this.render_frequency_ja
%ul{ class: [ :en , :text_en ] }<
  = this.render_dc_date_en
  = this.render_next_update_time_en
  = this.render_frequency_en
  HAML
end

#render_title(include_train_location_infos, include_delay) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tokyo_metro/app/renderer/real_time_infos/meta_datum/train_location_infos.rb', line 24

def render_title( include_train_location_infos , include_delay )
  h_locals_i = {
    this: self ,
    include_train_location_infos: include_train_location_infos ,
    include_delay: include_delay
  }
  h.render inline: <<-HAML , type: :haml , locals: h_locals_i
%ul{ class: :titles }
- if include_train_location_infos
  = this.render_title_of_train_location_infos
- if include_delay
  = this.render_title_of_current_delay
  HAML
end

#render_title_of_current_delayObject



39
40
41
# File 'lib/tokyo_metro/app/renderer/real_time_infos/meta_datum/train_location_infos.rb', line 39

def render_title_of_current_delay
  render_title_of_each_content( :delay , "現在の遅れ" , "Delay" )
end

#render_title_of_train_location_infosObject



43
44
45
# File 'lib/tokyo_metro/app/renderer/real_time_infos/meta_datum/train_location_infos.rb', line 43

def render_title_of_train_location_infos
  render_title_of_each_content( :train_location , ::TrainLocationDecorator.common_title_ja , ::TrainLocationDecorator.common_title_en )
end