Project

General

Profile

Bug #14483 ยป method-docs.patch

zverok (Victor Shepelev), 02/16/2018 11:54 AM

View differences:

proc.c
808 808
    return proc_new(rb_cProc, TRUE);
809 809
}
810 810

  
811
/*  Document-method: ===
811
/*  Document-method: Proc#===
812 812
 *
813 813
 *  call-seq:
814 814
 *     proc === obj   -> result_of_proc
......
821 821
/* CHECKME: are the argument checking semantics correct? */
822 822

  
823 823
/*
824
 *  Document-method: []
825
 *  Document-method: call
826
 *  Document-method: yield
824
 *  Document-method: Proc#[]
825
 *  Document-method: Proc#call
826
 *  Document-method: Proc#yield
827 827
 *
828 828
 *  call-seq:
829 829
 *     prc.call(params,...)   -> obj
......
1492 1492
 *     meth.call(9)                 #=> 81
1493 1493
 *     [ 1, 2, 3 ].collect(&meth)   #=> [1, 4, 9]
1494 1494
 *
1495
 *     [ 1, 2, 3 ].each(&method(:puts)) #=> prints 1, 2, 3
1496
 *
1497
 *     require 'date'
1498
 *     %w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
1499
 *     #=> [#<Date: 2017-03-01 ((2457814j,0s,0n),+0s,2299161j)>, #<Date: 2017-03-02 ((2457815j,0s,0n),+0s,2299161j)>]
1495 1500
 */
1496 1501

  
1497 1502
/*
......
1586 1591
 *     meth.receiver    -> object
1587 1592
 *
1588 1593
 *  Returns the bound receiver of the method object.
1594
 *
1595
 *    (1..3).method(:map).receiver # => 1..3
1589 1596
 */
1590 1597

  
1591 1598
static VALUE
......
1640 1647
 *     meth.owner    -> class_or_module
1641 1648
 *
1642 1649
 *  Returns the class or module that defines the method.
1650
 *  See also receiver.
1651
 *
1652
 *    (1..3).method(:map).owner #=> Enumerable
1643 1653
 */
1644 1654

  
1645 1655
static VALUE
......
1722 1732
 *     l = Demo.new('Fred')
1723 1733
 *     m = l.method("hello")
1724 1734
 *     m.call   #=> "Hello, @iv = Fred"
1735
 *
1736
 *  Note that <code>Method</code> implements <code>to_proc</code> method,
1737
 *  which means it can be used with iterators.
1738
 *
1739
 *     [ 1, 2, 3 ].each(&method(:puts)) # => prints 3 lines to stdout
1740
 *
1741
 *     out = File.open('test.txt', 'w')
1742
 *     [ 1, 2, 3 ].each(&out.method(:puts)) # => prints 3 lines to file
1743
 *
1744
 *     require 'date'
1745
 *     %w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
1746
 *     #=> [#<Date: 2017-03-01 ((2457814j,0s,0n),+0s,2299161j)>, #<Date: 2017-03-02 ((2457815j,0s,0n),+0s,2299161j)>]
1725 1747
 */
1726 1748

  
1727 1749
VALUE
......
2070 2092
    return clone;
2071 2093
}
2072 2094

  
2095
/*  Document-method: Method#===
2096
 *
2097
 *  call-seq:
2098
 *     method === obj   -> result_of_method
2099
 *
2100
 *  Invokes the method with +obj+ as the parameter like #call. It
2101
 *  is to allow a method object to be a target of +when+ clause in a case
2102
 *  statement.
2103
 *
2104
 *      require 'prime'
2105
 *
2106
 *      case 1373
2107
 *      when Prime.method(:prime?)
2108
 *        # ....
2109
 *      end
2110
 */
2111

  
2112

  
2073 2113
/*
2074 2114
 *  call-seq:
2075 2115
 *     meth.call(args, ...)    -> obj
......
2583 2623
 *   meth.to_s      ->  string
2584 2624
 *   meth.inspect   ->  string
2585 2625
 *
2586
 *  Returns the name of the underlying method.
2626
 *  Returns a human-readable description of the underlying method.
2587 2627
 *
2588 2628
 *    "cat".method(:count).inspect   #=> "#<Method: String#count>"
2629
 *    (1..3).method(:map).inspect    #=> "#<Method: Range(Enumerable)#map>"
2630
 *
2631
 *  In the latter case, method description includes the "owner" of original
2632
 *  method (+Enumerable+ module, which is included into +Range+).
2589 2633
 */
2590 2634

  
2591 2635
static VALUE