| | 12 | # |
|---|
| | 13 | # ==== Examples |
|---|
| | 14 | # ["Lions", "tigers", "bears"].to_sentence |
|---|
| | 15 | # # => "Lions, tigers, and bears" |
|---|
| | 16 | # |
|---|
| | 17 | # ["Active Record", "Action Pack", "Active Resource"].to_sentence(:connector => "or") |
|---|
| | 18 | # # => "Active Record, Action Pack, or Active Resource" |
|---|
| | 19 | # |
|---|
| | 20 | # ["red", "green", "blue"].to_sentence(:skip_last_comma => true) |
|---|
| | 21 | # # => "red, green and blue" |
|---|
| | 22 | # |
|---|
| | 72 | # Attempts to convert the array and all of its elements to XML. All elements must respond to |
|---|
| | 73 | # to_xml or an error will be raised. |
|---|
| | 74 | # |
|---|
| | 75 | # ==== Options |
|---|
| | 76 | # * <tt>:root</tt> - Sets the name for the root elements in the generated XML |
|---|
| | 77 | # * <tt>:children</tt> - Sets the name for the child elements in the generated XML |
|---|
| | 78 | # * <tt>:indent</tt> - Sets the how many spaces will be used to indent the generated XML |
|---|
| | 79 | # * <tt>:builder</tt> - Allows you to provide your own Builder instance to use |
|---|
| | 80 | # |
|---|
| | 81 | # ==== Examples |
|---|
| | 82 | # |
|---|
| | 83 | # [1,2,3].to_xml |
|---|
| | 84 | # # => RuntimeError: Not all elements respond to to_xml |
|---|
| | 85 | # |
|---|
| | 86 | # [{'key' => 'value', 'key2' => 'value'}, {'name' => 'Ruby on Rails'}].to_xml |
|---|
| | 87 | # # => "<?xml version=\"1.0\" encoding=\"UTF-8\"?> |
|---|
| | 88 | # <records type=\"array\"> |
|---|
| | 89 | # <record> |
|---|
| | 90 | # <key2>value</key2> |
|---|
| | 91 | # <key>value</key> |
|---|
| | 92 | # </record> |
|---|
| | 93 | # <record> |
|---|
| | 94 | # <name>Ruby on Rails</name> |
|---|
| | 95 | # </record> |
|---|
| | 96 | # </records>" |
|---|
| | 97 | # |
|---|
| | 98 | # [{'key' => 'value'}].to_xml(:root => 'beets', :children => 'carrots') |
|---|
| | 99 | # # => "<?xml version=\"1.0\" encoding=\"UTF-8\"?> |
|---|
| | 100 | # <beets type=\"array\"> |
|---|
| | 101 | # <carrots> |
|---|
| | 102 | # <key>value</key> |
|---|
| | 103 | # </carrots> |
|---|
| | 104 | # </beets>" |
|---|