Class: TokyoMetro::Factory::Decorate::Api::TrainLocation::Info

Inherits:
MetaClass::RealTime::Info show all
Defined in:
lib/tokyo_metro/factory/decorate/api/train_location/info.rb

Defined Under Namespace

Classes: Delay, TrainType

Instance Attribute Summary collapse

Attributes inherited from MetaClass::RealTime::Info

#object

Instance Method Summary collapse

Constructor Details

#initialize(request, obj, railway_line) ⇒ Info

Returns a new instance of Info.



3
4
5
6
7
8
# File 'lib/tokyo_metro/factory/decorate/api/train_location/info.rb', line 3

def initialize( request , obj , railway_line )
  super( request , obj )
  @railway_line = railway_line
  set_station_infos
  set_place_id
end

Instance Attribute Details

#place_idObject (readonly)

Returns the value of attribute place_id.



11
12
13
# File 'lib/tokyo_metro/factory/decorate/api/train_location/info.rb', line 11

def place_id
  @place_id
end

#railway_lineObject (readonly)

Returns the value of attribute railway_line.



10
11
12
# File 'lib/tokyo_metro/factory/decorate/api/train_location/info.rb', line 10

def railway_line
  @railway_line
end

Instance Method Details

#renderObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/tokyo_metro/factory/decorate/api/train_location/info.rb', line 13

def render
  h_locals_i = {
    this: self ,
    railway_line_of_train: railway_line_of_train ,
    train_type_decorated: train_type_decorated ,
    starting_station_decorated: starting_station_decorated ,
    terminal_station_decorated: terminal_station_decorated ,
    train_owner_decorated: train_owner_decorated ,
    to_render_train_type: render_train_type? ,
    to_render_train_owner: render_train_owner?
  }
  h.render inline: <<-HAML , type: :haml , locals: h_locals_i
%li{ class: [ :train_location , railway_line_of_train.css_class_name , :clearfix ] , id: this.object.train_number.downcase }
%div{ class: :train_fundamental_infos }
  = railway_line_of_train.decorate.render_matrix( make_link_to_railway_line: false , size: :very_small )
  - if to_render_train_type
    = train_type_decorated.render_in_train_location
  = terminal_station_decorated.render_as_terminal_station
= this.render_current_position
%ul{ class: :sub_infos }
  = this.render_delay
  = this.render_train_number
  = starting_station_decorated.render_as_starting_station
  - if to_render_train_owner
    = train_owner_decorated.in_train_location.render
  HAML
end

#render_current_positionObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/tokyo_metro/factory/decorate/api/train_location/info.rb', line 41

def render_current_position
  h.render inline: <<-HAML , type: :haml , locals: { request: request , station_infos: @station_infos }
%div{ class: :current_position }
%p{ class: [ :title_of_current_position , :text_ja ] }
  = "現在位置"
  %span{ class: :text_en }<
    = "Now at"
%div{ class: :station_infos }<
  - station_infos.each.with_index(1) do | station_info , i |
    = station_info.decorate.train_location.render_name
    - unless i == station_infos.length
      %div{ class: :arrow }
        = ::TokyoMetro::App::Renderer::Icon.caret_down( request , 2 ).render
  HAML
end

#render_delayObject



57
58
59
# File 'lib/tokyo_metro/factory/decorate/api/train_location/info.rb', line 57

def render_delay
  object.delay_instance.decorate( request ).render_in_location_of_each_train
end

#render_train_numberObject



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/tokyo_metro/factory/decorate/api/train_location/info.rb', line 61

def render_train_number
  str = object.train_number
  h.render inline: <<-HAML , type: :haml , locals: { str: str }
%li{ class: [ :train_number , :sub_info , :clearfix ] }
%div{ class: :title_of_train_number }
  %p{ class: :text_ja }<
    = "列車番号"
  %p{ class: :text_en }<
    = "Train number "
%div{ class: [ :train_number_text , :text_en ] }<
  = str
  HAML
end