Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3816

Show
Ignore:
Timestamp:
03/08/06 16:13:13 (3 years ago)
Author:
xal
Message:

reverted #to_sentence to use red, green, and blue style

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/lib/active_support/core_ext/array/conversions.rb

    r3812 r3816  
    55        # Converts the array to comma-seperated sentence where the last element is joined by the connector word. Options: 
    66        # * <tt>:connector</tt>: The word used to join the last element in arrays with more than two elements (default: "and") 
    7         # * <tt>:skip_last_comma</tt>: Set to false to return "a, b, and c" instead of "a, b and c". 
     7        # * <tt>:skip_last_comma</tt>: Set to true to return "a, b, and c" instead of "a, b and c". 
    88        def to_sentence(options = {}) 
    99          options.assert_valid_keys(:connector, :skip_last_comma) 
    10           options.reverse_merge! :connector => 'and', :skip_last_comma => tru
     10          options.reverse_merge! :connector => 'and', :skip_last_comma => fals
    1111           
    1212          case length 
  • trunk/activesupport/test/core_ext/array_ext_test.rb

    r3812 r3816  
    1919    assert_equal "one", ['one'].to_sentence 
    2020    assert_equal "one and two", ['one', 'two'].to_sentence 
    21     assert_equal "one, two and three", ['one', 'two', 'three'].to_sentence 
     21    assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence 
    2222     
    2323  end 
    2424   
    2525  def test_to_sentence_with_connector 
    26     assert_equal "one, two and also three", ['one', 'two', 'three'].to_sentence(:connector => 'and also') 
     26    assert_equal "one, two, and also three", ['one', 'two', 'three'].to_sentence(:connector => 'and also') 
    2727  end 
    2828