| Server IP : 162.214.74.102 / Your IP : 216.73.217.21 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/proc/self/root/opt/cpanel/ea-ruby24/root/usr/share/ri/system/Object/ |
Upload File : |
U:RDoc::AnyMethod[iI"
enum_for:ETI"Object#enum_for;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"JCreates a new Enumerator which will enumerate by calling +method+ on ;TI""+obj+, passing +args+ if any.;To:RDoc::Markup::BlankLine o;
; [I"CIf a block is given, it will be used to calculate the size of ;TI"Ithe enumerator without the need to iterate it (see Enumerator#size).;T@S:RDoc::Markup::Heading:
leveli: textI"
Examples;T@o:RDoc::Markup::Verbatim; [I"str = "xyz"
;TI"
;TI"%enum = str.enum_for(:each_byte)
;TI"enum.each { |b| puts b }
;TI"# => 120
;TI"# => 121
;TI"# => 122
;TI"
;TI";# protect an array from being modified by some_method
;TI"a = [1, 2, 3]
;TI"some_method(a.to_enum)
;T:@format0o;
; [I"=It is typical to call to_enum when defining methods for ;TI"6a generic Enumerable, in case no block is passed.;T@o;
; [I"HHere is such an example, with parameter passing and a sizing block:;T@o;; [I"module Enumerable
;TI"A # a generic method to repeat the values of any enumerable
;TI" def repeat(n)
;TI"; raise ArgumentError, "#{n} is negative!" if n < 0
;TI" unless block_given?
;TI"I return to_enum(__method__, n) do # __method__ is :repeat here
;TI"< sz = size # Call size and multiply by n...
;TI"B sz * n if sz # but return nil if size itself is nil
;TI" end
;TI"
end
;TI" each do |*val|
;TI"" n.times { yield *val }
;TI"
end
;TI" end
;TI" end
;TI"
;TI".%i[hello world].repeat(2) { |w| puts w }
;TI"6 # => Prints 'hello', 'hello', 'world', 'world'
;TI"enum = (1..14).repeat(3)
;TI"> # => returns an Enumerator when called without a block
;TI"%enum.first(4) # => [1, 1, 1, 2]
;TI"enum.size # => 42;T;0:
@fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"zobj.enum_for(method = :each, *args) -> enum
obj.enum_for(method = :each, *args){|*args| block} -> enum;T0[ I"(*args);T@BFI"Object;TcRDoc::NormalClass00