codoc 0.1.0

Unified documentation parser for Ruby and TypeScript codebases
Documentation
# frozen_string_literal: true

# A class demonstrating various method signatures.
class MethodExamples
  # Method with no parameters.
  #
  # @return [String]
  def no_params
    "hello"
  end

  # Method with required parameters.
  #
  # @param first [String] the first value
  # @param second [Integer] the second value
  # @return [String]
  def required_params(first, second)
    "#{first}-#{second}"
  end

  # Method with optional parameters.
  #
  # @param value [String] the value
  # @param prefix [String] optional prefix
  # @param suffix [String] optional suffix
  # @return [String]
  def optional_params(value, prefix = "[", suffix = "]")
    "#{prefix}#{value}#{suffix}"
  end

  # Method with keyword arguments.
  #
  # @param name [String] the name
  # @param age [Integer] the age
  # @param active [Boolean] whether active
  # @return [Hash]
  def keyword_params(name:, age:, active: true)
    { name: name, age: age, active: active }
  end

  # Method with splat parameters.
  #
  # @param items [Array<String>] variable number of items
  # @return [Integer] the count
  def splat_params(*items)
    items.length
  end

  # Method with double splat (keyword splat).
  #
  # @param base [Hash] the base options
  # @param options [Hash] additional options
  # @return [Hash]
  def double_splat_params(base = {}, **options)
    base.merge(options)
  end

  # Method with block parameter.
  #
  # @param items [Array] the items to process
  # @yield [item] Yields each item
  # @yieldparam item [Object] the current item
  # @yieldreturn [Object] the transformed item
  # @return [Array]
  def with_block(items, &block)
    items.map(&block)
  end

  # Method that raises exceptions.
  #
  # @param value [Integer] the value to check
  # @raise [ArgumentError] if value is negative
  # @raise [RangeError] if value is too large
  # @return [Integer]
  def raising_method(value)
    raise ArgumentError, "negative" if value < 0
    raise RangeError, "too large" if value > 100
    value
  end

  protected

  # A protected method.
  #
  # @return [void]
  def protected_helper
    # implementation
  end

  private

  # A private method.
  #
  # @return [void]
  def private_helper
    # implementation
  end
end