Module: WorldFlags::Helper::View
- Defined in:
- lib/world_flags/helper/view.rb,
lib/world_flags/helper/view/util.rb
Defined Under Namespace
Modules: Util
Class Method Summary collapse
Instance Method Summary collapse
- #flag(code, *args) ⇒ Object
- #flag_title(code, *args) ⇒ Object
-
#flags(*args) ⇒ Object
should look up translation for each code.
- #flags_list(size = 24, options = {}, &block) ⇒ Object (also: #flag_list)
- #flags_title(*args) ⇒ Object
- #use_flags(size = 24) ⇒ Object
Class Method Details
.flag_sizes ⇒ Object
6 7 8 |
# File 'lib/world_flags/helper/view.rb', line 6 def self.flag_sizes [16, 24, 32, 48, 64] end |
Instance Method Details
#flag(code, *args) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/world_flags/helper/view.rb', line 44 def flag code, *args = args. name = args.first.kind_of?(String) ? args.first : WorldFlags.label(code, ) label = WorldFlags::Helper::View::Util.label_for title = WorldFlags::Helper::View::Util.title_for name, content_tag WorldFlags.flag_tag, label.html_safe, WorldFlags::Helper::View::Util.(code, title, name, ) end |
#flag_title(code, *args) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/world_flags/helper/view.rb', line 54 def flag_title code, *args = args. name = args.first.kind_of?(String) ? args.first : WorldFlags.label(code, ) flag code, name, .merge(:title => true) end |
#flags(*args) ⇒ Object
should look up translation for each code
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/world_flags/helper/view.rb', line 24 def flags *args = args. args.flatten! args.inject("") do |res, elem| case elem when String, Symbol code = elem name = WorldFlags.label(code, ) else raise ArgumentError, "Bad argument: #{args}, must be Array" end res << flag(code, name, ) end.html_safe end |
#flags_list(size = 24, options = {}, &block) ⇒ Object Also known as: flag_list
10 11 12 13 14 15 16 17 18 |
# File 'lib/world_flags/helper/view.rb', line 10 def flags_list size = 24, = {}, &block raise "Missing block" unless block_given? unless WorldFlags::Helper::View.flag_sizes.include?(size.to_i) raise "Supported sizes are only #{WorldFlags::Helper::View.flag_sizes}" end content = capture(&block) xclass = [:class] ? " #{[:class]}" : '' content_tag WorldFlags.flag_list_tag, content, :class => "f#{size} flags#{xclass}" end |
#flags_title(*args) ⇒ Object
39 40 41 42 |
# File 'lib/world_flags/helper/view.rb', line 39 def flags_title *args = args. flags args, .merge(:title => true) end |
#use_flags(size = 24) ⇒ Object
61 62 63 |
# File 'lib/world_flags/helper/view.rb', line 61 def use_flags size = 24 stylesheet_link_tag "flags/flags#{size}" end |