• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

mrubyを超漢字で動作させる


Commit MetaInfo

Revisão45e70e4dd67d4a407260f79417a48063237c9e28 (tree)
Hora2015-10-21 00:16:47
AutorSeba Gamboa <me@sagm...>
CommiterSeba Gamboa

Mensagem de Log

Fix enumerator doc errors

Mudança Sumário

Diff

--- a/mrbgems/mruby-enumerator/mrblib/enumerator.rb
+++ b/mrbgems/mruby-enumerator/mrblib/enumerator.rb
@@ -6,93 +6,92 @@
66 # A class which allows both internal and external iteration.
77 #
88 # An Enumerator can be created by the following methods.
9-# - Kernel#to_enum
10-# - Kernel#enum_for
11-# - Enumerator.new
9+# - {Kernel#to_enum}
10+# - {Kernel#enum_for}
11+# - {Enumerator#initialize Enumerator.new}
1212 #
1313 # Most methods have two forms: a block form where the contents
1414 # are evaluated for each item in the enumeration, and a non-block form
1515 # which returns a new Enumerator wrapping the iteration.
1616 #
17-# enumerator = %w(one two three).each
18-# puts enumerator.class # => Enumerator
17+# enumerator = %w(one two three).each
18+# puts enumerator.class # => Enumerator
1919 #
20-# enumerator.each_with_object("foo") do |item, obj|
21-# puts "#{obj}: #{item}"
22-# end
20+# enumerator.each_with_object("foo") do |item, obj|
21+# puts "#{obj}: #{item}"
22+# end
2323 #
24-# # foo: one
25-# # foo: two
26-# # foo: three
24+# # foo: one
25+# # foo: two
26+# # foo: three
2727 #
28-# enum_with_obj = enumerator.each_with_object("foo")
29-# puts enum_with_obj.class # => Enumerator
28+# enum_with_obj = enumerator.each_with_object("foo")
29+# puts enum_with_obj.class # => Enumerator
3030 #
31-# enum_with_obj.each do |item, obj|
32-# puts "#{obj}: #{item}"
33-# end
31+# enum_with_obj.each do |item, obj|
32+# puts "#{obj}: #{item}"
33+# end
3434 #
35-# # foo: one
36-# # foo: two
37-# # foo: three
35+# # foo: one
36+# # foo: two
37+# # foo: three
3838 #
3939 # This allows you to chain Enumerators together. For example, you
4040 # can map a list's elements to strings containing the index
4141 # and the element as a string via:
4242 #
43-# puts %w[foo bar baz].map.with_index { |w, i| "#{i}:#{w}" }
44-# # => ["0:foo", "1:bar", "2:baz"]
43+# puts %w[foo bar baz].map.with_index { |w, i| "#{i}:#{w}" }
44+# # => ["0:foo", "1:bar", "2:baz"]
4545 #
4646 # An Enumerator can also be used as an external iterator.
4747 # For example, Enumerator#next returns the next value of the iterator
4848 # or raises StopIteration if the Enumerator is at the end.
4949 #
50-# e = [1,2,3].each # returns an enumerator object.
51-# puts e.next # => 1
52-# puts e.next # => 2
53-# puts e.next # => 3
54-# puts e.next # raises StopIteration
50+# e = [1,2,3].each # returns an enumerator object.
51+# puts e.next # => 1
52+# puts e.next # => 2
53+# puts e.next # => 3
54+# puts e.next # raises StopIteration
5555 #
5656 # You can use this to implement an internal iterator as follows:
5757 #
58-# def ext_each(e)
59-# while true
60-# begin
61-# vs = e.next_values
62-# rescue StopIteration
63-# return $!.result
58+# def ext_each(e)
59+# while true
60+# begin
61+# vs = e.next_values
62+# rescue StopIteration
63+# return $!.result
64+# end
65+# y = yield(*vs)
66+# e.feed y
67+# end
6468 # end
65-# y = yield(*vs)
66-# e.feed y
67-# end
68-# end
6969 #
70-# o = Object.new
70+# o = Object.new
7171 #
72-# def o.each
73-# puts yield
74-# puts yield(1)
75-# puts yield(1, 2)
76-# 3
77-# end
72+# def o.each
73+# puts yield
74+# puts yield(1)
75+# puts yield(1, 2)
76+# 3
77+# end
7878 #
79-# # use o.each as an internal iterator directly.
80-# puts o.each {|*x| puts x; [:b, *x] }
81-# # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
79+# # use o.each as an internal iterator directly.
80+# puts o.each {|*x| puts x; [:b, *x] }
81+# # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
8282 #
83-# # convert o.each to an external iterator for
84-# # implementing an internal iterator.
85-# puts ext_each(o.to_enum) {|*x| puts x; [:b, *x] }
86-# # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
83+# # convert o.each to an external iterator for
84+# # implementing an internal iterator.
85+# puts ext_each(o.to_enum) {|*x| puts x; [:b, *x] }
86+# # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
8787 #
8888 # @mrbgem mruby-enumerator
8989 class Enumerator
9090 include Enumerable
9191
9292 ##
93- # call-seq:
94- # Enumerator.new(size = nil) { |yielder| ... }
95- # Enumerator.new(obj, method = :each, *args)
93+ # @overload initialize(size = nil, &block)
94+ # @overload initialize(obj, method = :each, *args)
9695 #
9796 # Creates a new Enumerator object, which can be used as an
9897 # Enumerable.
@@ -101,15 +100,15 @@ class Enumerator
101100 # which a "yielder" object, given as block parameter, can be used to
102101 # yield a value by calling the +yield+ method (aliased as +<<+):
103102 #
104- # fib = Enumerator.new do |y|
105- # a = b = 1
106- # loop do
107- # y << a
108- # a, b = b, a + b
103+ # fib = Enumerator.new do |y|
104+ # a = b = 1
105+ # loop do
106+ # y << a
107+ # a, b = b, a + b
108+ # end
109109 # end
110- # end
111110 #
112- # p fib.take(10) # => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
111+ # p fib.take(10) # => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
113112 #
114113 def initialize(obj=nil, meth=:each, *args, &block)
115114 if block_given?
@@ -189,8 +188,7 @@ class Enumerator
189188 #
190189 # If no block is given, returns a new Enumerator.
191190 #
192- # === Example
193- #
191+ # @example
194192 # to_three = Enumerator.new do |y|
195193 # 3.times do |x|
196194 # y << x