Class: TokyoMetro::App::Renderer::Twitter

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

Defined Under Namespace

Classes: Header

Instance Method Summary collapse

Constructor Details

#initialize(request, setting, railway_lines = nil, visibility: :visible) ⇒ Twitter

Returns a new instance of Twitter.



3
4
5
6
7
8
9
10
11
# File 'lib/tokyo_metro/app/renderer/twitter.rb', line 3

def initialize( request , setting , railway_lines = nil , visibility: :visible )
  raise "Error" unless setting == :tokyo_metro or setting == :railway_lines
  raise "Error" if setting == :railway_lines and railway_lines.blank?
  raise "Error" unless visibility == :visible or visibility == :hidden
  super( request )
  @setting = setting
  @railway_lines = [ railway_lines ].flatten
  @visibility = visibility
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
# File 'lib/tokyo_metro/app/renderer/twitter.rb', line 13

def render
  h.render inline: <<-HAML , type: :haml , locals: h_locals
%div{ id: :twitters , class: visibility }
= ::TokyoMetro::App::Renderer::Twitter::Header.new( request , visibility ).render
%div{ id: :twitter_accounts }
  - # %ul{ id: :twitter_tabs_for_each_acount }
  - #   %li{ id: :twitter_tab_tokyo_metro }<
  - #    = ::Operator.tokyo_metro.decorate.render_logo
  - if setting == :tokyo_metro
    %div{ id: :tweets_of_tokyo_metro , class: :twitter_account }
      = ::ApplicationHelper.tokyo_metro.decorate.render_twitter_widget
  - elsif setting == :railway_lines
    - if railway_lines.length == 1
      = railway_lines.first.decorate.render_twitter_widget
    - else
      - railway_lines.each do | railway_line |
        = railway_line.decorate.render_twitter_widget
= ::TwitterAccountDecorator.embed_twitter_script
  HAML
end