1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# frozen_string_literal: true
# A class demonstrating various Yardoc documentation tags.
#
# This class shows how different documentation tags are parsed.
#
# @author John Doe
# @since 1.0.0
# @see https://example.com Documentation
# @note This is an important note about the class.
# @todo Add more features
# A method with comprehensive documentation.
#
# This method demonstrates most Yardoc tags.
#
# @param name [String] the name parameter with a longer description
# that spans multiple lines for testing purposes
# @param options [Hash] the options hash
# @option options [Integer] :timeout the timeout in seconds
# @option options [Boolean] :retry whether to retry on failure
# @option options [String] :format the output format
#
# @return [Hash] the result containing:
# - `:status` - the status code
# - `:data` - the response data
#
# @raise [ArgumentError] if name is empty
# @raise [RuntimeError] if operation fails
#
# @example Basic usage
# result = obj.comprehensive("test")
# result[:status] #=> 200
#
# @example With options
# result = obj.comprehensive("test", timeout: 60, retry: true)
#
# @see #simple_method
# @note This method may be slow for large inputs.
# @deprecated Use {#new_method} instead.
{ status: 200, data: name }
end
# A method that yields to a block.
#
# @param items [Array<String>] the items to iterate
# @yield [item, index] Yields each item with its index
# @yieldparam item [String] the current item
# @yieldparam index [Integer] the current index
# @yieldreturn [Boolean] whether to continue
# @return [Integer] the number of items processed
items.each_with_index do
break unless yield(item, index)
end.length
end
# A simple method for reference.
#
# @return [String]
end
# The new recommended method.
#
# @param name [String] the name
# @return [Hash]
comprehensive(name)
end
# A method with union types.
#
# @param value [String, Integer, nil] the value (can be multiple types)
# @return [String, nil] the result or nil
value&.to_s
end
# A method with array types.
#
# @param items [Array<Hash{Symbol => String}>] array of hashes
# @return [Array<String>] array of strings
items.map { h.values.join }
end
end