Class: TokyoMetro::Factory::Decorate::Api::TrainOperation::Common

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

Direct Known Subclasses

Info, Info::BasicError

Instance Attribute Summary collapse

Attributes inherited from MetaClass::RealTime::Info

#object

Instance Method Summary collapse

Constructor Details

#initialize(request, obj, railway_line, controller) ⇒ Common

Returns a new instance of Common.



3
4
5
6
7
# File 'lib/tokyo_metro/factory/decorate/api/train_operation/common.rb', line 3

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

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



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

def controller
  @controller
end

#railway_lineObject (readonly)

Returns the value of attribute railway_line.



9
10
11
# File 'lib/tokyo_metro/factory/decorate/api/train_operation/common.rb', line 9

def railway_line
  @railway_line
end

#status_typeObject (readonly)

Returns the value of attribute status_type.



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

def status_type
  @status_type
end

Instance Method Details

#renderObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/tokyo_metro/factory/decorate/api/train_operation/common.rb', line 13

def render
  h.render inline: <<-HAML , type: :haml , locals: { this: self }
%li{ class: [ :train_operation_info , :railway_line , :clearfix ] }
= this.railway_line.decorate.render_matrix( make_link_to_railway_line: true , size: :small , link_controller_name: this.controller )
%div{ class: [ :status , this.status_type ] }
  %div{ class: :infos }
    = this.render_status_icon_and_text
    = this.render_status_additional_infos
  HAML
end

#render_status_icon_and_textObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tokyo_metro/factory/decorate/api/train_operation/common.rb', line 24

def render_status_icon_and_text
  h.render inline: <<-HAML , type: :haml , locals: { this: self }
%div{ class: :icon }<
= ::TokyoMetro::App::Renderer::Icon.send( this.status_type , request , 3 ).render
%div{ class: :text }
%p{ class: :text_ja }<
  = this.status_text_ja
%p{ class: :text_en }<
  = this.status_text_en
  HAML
end