MCP server for accessing Ruby YARD documentation in a project
1# Example Ruby file for testing YARD MCP server
2# This file contains various documented Ruby constructs
3
4# A simple user class for demonstration
5# @author Test Author
6# @version 1.0
7class User
8 # @return [String] the user's name
9 attr_reader :name
10
11 # @return [String] the user's email
12 attr_accessor :email
13
14 # Initialize a new user
15 # @param name [String] the user's name
16 # @param email [String] the user's email address
17 # @example Create a new user
18 # user = User.new("John Doe", "john@example.com")
19 def initialize(name, email)
20 @name = name
21 @email = email
22 end
23
24 # Get the user's full display name
25 # @return [String] formatted display name
26 # @example
27 # user.display_name #=> "John Doe <john@example.com>"
28 def display_name
29 "#{@name} <#{@email}>"
30 end
31
32 # Check if the user is valid
33 # @return [Boolean] true if user has name and email
34 def valid?
35 !@name.nil? && !@name.empty? && !@email.nil? && !@email.empty?
36 end
37
38 # Class method to create admin user
39 # @param name [String] admin name
40 # @return [User] new admin user
41 def self.create_admin(name)
42 new(name, "#{name.downcase}@admin.com")
43 end
44end
45
46# A utility module for string operations
47module StringUtils
48 # Convert string to title case
49 # @param str [String] input string
50 # @return [String] title cased string
51 # @example
52 # StringUtils.titleize("hello world") #=> "Hello World"
53 def self.titleize(str)
54 str.split.map(&:capitalize).join(' ')
55 end
56end