Class: TokyoMetro::App::Renderer::Concerns::Link::Normal::MetaClass
- Inherits:
-
Factory::Decorate::MetaClass
- Object
- RailsDecorateFactory
- Factory::Decorate::MetaClass
- TokyoMetro::App::Renderer::Concerns::Link::Normal::MetaClass
- Defined in:
- lib/tokyo_metro/app/renderer/concerns/link/normal/meta_class.rb
Direct Known Subclasses
Constant Summary collapse
- ICON_SIZE =
1
Instance Method Summary collapse
-
#initialize(request, title_ja, title_en, url, icon_name: nil, class_name_of_whole_domain: nil, class_name_of_link: :link, class_name_of_div_domain: nil, open_another_window: false, size: :normal, additional_info: nil, additional_info_position: nil, link_to_another_website: false) ⇒ MetaClass
constructor
A new instance of MetaClass.
- #render ⇒ Object
Constructor Details
#initialize(request, title_ja, title_en, url, icon_name: nil, class_name_of_whole_domain: nil, class_name_of_link: :link, class_name_of_div_domain: nil, open_another_window: false, size: :normal, additional_info: nil, additional_info_position: nil, link_to_another_website: false) ⇒ MetaClass
Returns a new instance of MetaClass.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tokyo_metro/app/renderer/concerns/link/normal/meta_class.rb', line 5 def initialize( request , title_ja , title_en , url , icon_name: nil , class_name_of_whole_domain: nil , class_name_of_link: :link , class_name_of_div_domain: nil , open_another_window: false , size: :normal , additional_info: nil , additional_info_position: nil , link_to_another_website: false ) super( request ) raise "Error" if title_ja.blank? and title_en.blank? raise "Error" if class_name_of_div_domain.blank? raise "Error" if additional_info.present? and additional_info_position.blank? raise "Error" if additional_info.blank? and additional_info_position.present? raise "Error" if link_to_another_website and !( open_another_window ) @title_ja = title_ja @title_en = title_en @url = url @icon_name = icon_name @class_name_of_whole_domain = class_name_of_whole_domain @class_name_of_link = class_name_of_link @class_name_of_div_domain = class_name_of_div_domain @open_another_window = open_another_window @size = size @additional_info = additional_info @additional_info_position = additional_info_position @link_to_another_website = link_to_another_website end |
Instance Method Details
#render ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/tokyo_metro/app/renderer/concerns/link/normal/meta_class.rb', line 32 def render _h_locals = h_locals h.render inline: <<-HAML , type: :haml , locals: _h_locals %li{ class: [ li_class_name , :clearfix ].flatten }< = v.link_to_unless( link_to_current_page , "" , url , only_path_setting: false , class: class_name_of_link , target: target ) %div{ class: [ class_name_of_div_domain , :clearfix ].flatten }< - # Icon %div{ class: :icon } - if icon_name.present? = ::TokyoMetro::App::Renderer::Icon.send( icon_name , request , icon_size ).render - else %div{ class: :icon_img }< - # Title - if title_ja.present? and title_en.present? - # Title (1) %div{ class: [ :text , :clearfix ] } - if title_ja.instance_of?( ::Array ) %div{ class: :text_ja }< - title_ja.each do | row | %p< = row - else %p{ class: :text_ja }< = title_ja - if title_en.instance_of?( ::Array ) %div{ class: :text_en }< - title_ja.each do | row | %p< = row - else %p{ class: :text_en }< = title_en - if additional_info.present? = additional_info.call - else - # Title (2) - div_classes = [ :text_large ] - if title_ja.present? - text = title_ja - div_classes << :text_ja - elsif title_en.present? - text = title_en - div_classes << :text_en %div{ class: div_classes } - if text.instance_of?( ::Array ) - text.each do | row | %p< = row - else %p< = text - if additional_info.present? = additional_info.call - # External Link - if open_another_window - if link_to_another_website %div{ class: :link_to_another_website } = ::TokyoMetro::App::Renderer::Icon.link_to_another_website( request , 1 ).render - else %div{ class: :open_another_window } = ::TokyoMetro::App::Renderer::Icon.open_another_window( request , 1 ).render HAML end |