mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-enumerator: add call-seq documentation for inspect and size methods
Added missing call-seq documentation for two Enumerator methods in mrblib/enumerator.rb: ## Enumerator Instance Methods: - inspect: returns string representation of the enumerator showing the underlying object, method, and arguments in a readable debug format with examples for different enumerator types - size: returns the size of the enumerator if calculable, or nil if it cannot be determined lazily, with examples showing finite and infinite enumerators Co-authored-by: Atlassian Rovo Dev
This commit is contained in:
@@ -229,6 +229,15 @@ class Enumerator
|
||||
object
|
||||
end
|
||||
|
||||
##
|
||||
# call-seq:
|
||||
# enum.inspect -> string
|
||||
#
|
||||
# Returns a string representation of the enumerator.
|
||||
#
|
||||
# [1, 2, 3].each.inspect #=> "#<Enumerator: [1, 2, 3]:each>"
|
||||
# [1, 2, 3].map.inspect #=> "#<Enumerator: [1, 2, 3]:map>"
|
||||
#
|
||||
def inspect
|
||||
if @args && @args.size > 0
|
||||
args = @args.join(", ")
|
||||
@@ -238,6 +247,16 @@ class Enumerator
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# call-seq:
|
||||
# enum.size -> int, float, or nil
|
||||
#
|
||||
# Returns the size of the enumerator, or nil if it cannot be calculated lazily.
|
||||
#
|
||||
# [1, 2, 3].each.size #=> 3
|
||||
# (1..100).each.size #=> 100
|
||||
# loop.size #=> nil
|
||||
#
|
||||
def size
|
||||
if @size
|
||||
@size
|
||||
|
||||
Reference in New Issue
Block a user