Skip to content

Examples

Alecs edited this page Oct 11, 2023 · 1 revision

Customization Module - Examples

Welcome to the Examples page for the Customization module! Here, we provide practical demonstrations of how to use the Customization module to enhance text formatting in your Ruby terminal applications. These examples cover real-life scenarios where the module can be a valuable addition to your projects.

Real-Life Scenarios

How to Use

You can explore each scenario by clicking the respective links below. Each scenario includes a detailed explanation and code examples that illustrate how the Customization module can be applied in various practical situations.

Table of Contents

Let's Get Started

Click on the scenario links below to dive into each example:

Scenario 1: Creating a Stylish Command-Line Interface (CLI) Tool

In this scenario, we develop a CLI tool and explore how the Customization module can be used to improve the user experience. Discover how to format text to highlight important messages and make your CLI tool visually engaging.

Code Example:

# Import the Customization module
require 'customization'

# Create a welcome message
welcome_message = "Welcome to MyCLI Tool"
formatted_welcome = Customization.color_text(welcome_message, :green)
puts formatted_welcome

# Display an important notification
notification = "Important: Please proceed with caution."
formatted_notification = Customization.color_text(notification, :red)
puts formatted_notification

# Present a list of options with custom formatting
options = ["Option 1: Start", "Option 2: Help", "Option 3: Quit"]
formatted_options = options.map { |option| Customization.format_text(option, :bold) }
puts formatted_options

Scenario 2: Creating a Stylish Report Generator

If you're building a report generator tool, this scenario will guide you through creating visually appealing reports with headers, sections, and custom text formatting. Learn how to make your reports professional and polished.

Code Example:

# Import the Customization module
require 'customization'

# Create a report header
report_title = "Quarterly Sales Report"
formatted_title = Customization.format_text(report_title, :bold)
puts formatted_title

# Display section headers
section_1 = "Sales Overview"
formatted_section_1 = Customization.format_text(section_1, :underline)
puts formatted_section_1

section_2 = "Product Sales"
formatted_section_2 = Customization.format_text(section_2, :underline)
puts formatted_section_2

# Present data with custom formatting
product_data = "Product A: $10,000\nProduct B: $8,000"
formatted_data = Customization.color_text(product_data, :blue)
puts formatted_data

# Add a custom border around a note
note = "Note: Sales figures are in USD."
formatted_note = Customization.set_text_border(note, :double)
puts formatted_note

Scenario 3: Developing a Terminal Game

For text-based game developers, this scenario showcases how the Customization module can add style and engagement to your game. Explore text colorization, dynamic effects, and more to make your game interactive and exciting.

Code Example:

# Import the Customization module
require 'customization'

# Introduce the game with custom formatting
game_title = "The Quest for the Magic Amulet"
formatted_title = Customization.color_text(game_title, :yellow)
puts formatted_title

# Describe the game world
world_description = "You find yourself in a mysterious forest..."
formatted_description = Customization.color_text(world_description, :green)
puts formatted_description

# Display character status with dynamic effects
character_status = "Health: 100% | Stamina: 70%"
formatted_status = Customization.apply_blinking_effect(character_status)
puts formatted_status

# Show a dialogue with custom text shadow
dialogue = "Old Wizard: Welcome, young adventurer."
formatted_dialogue = Customization.apply_text_shadow(dialogue)
puts formatted_dialogue