Method: Merb::Router::Behavior.array_to_code
- Defined in:
- lib/merb-core/dispatch/router/behavior.rb
.array_to_code(arr) ⇒ Object
Parameters
- arr<Array>
-
The array to convert to a code string.
Returns
- String
-
The arr’s elements converted to string and joined with “ + ”, with any string elements surrounded by quotes.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/merb-core/dispatch/router/behavior.rb', line 48 def array_to_code(arr) code = '' arr.each_with_index do |part, i| code << ' + ' if i > 0 case part when Symbol code << part.to_s when String code << %{"#{part}"} else raise "Don't know how to compile array part: #{part.class} [#{i}]" end end code end |