1+ // Copyright (c) 2025 A Bit of Help, Inc.
2+
3+ // Package measurement provides value objects related to measurement information.
4+ //
5+ // This package contains value objects that represent different types of measurements
6+ // such as monetary values, file sizes, memory sizes, percentages, ratings, and
7+ // temperatures. These value objects are immutable and follow the Value Object pattern
8+ // from Domain-Driven Design.
9+ //
10+ // Key value objects in this package:
11+ // - Money: Represents a monetary value with amount and currency
12+ // - FileSize: Represents a file size with different units (bytes, KB, MB, etc.)
13+ // - MemSize: Represents a memory size with different units (bytes, KB, MB, etc.)
14+ // - Percentage: Represents a percentage value
15+ // - Rating: Represents a rating value (e.g., 1-5 stars)
16+ // - Temperature: Represents a temperature value with different units
17+ //
18+ // Each value object provides methods for:
19+ // - Creating and validating instances
20+ // - String representation
21+ // - Equality comparison
22+ // - Conversion between different units or formats
23+ //
24+ // Many value objects also provide arithmetic operations appropriate to their domain:
25+ // - Money: Addition, subtraction, multiplication, division
26+ // - Percentage: Addition, subtraction, application to values
27+ // - Temperature: Conversion between units (Celsius, Fahrenheit, Kelvin)
28+ //
29+ // Example usage:
30+ //
31+ // // Create a new money value
32+ // amount := decimal.NewFromFloat(99.99)
33+ // money, err := measurement.NewMoney(amount, "USD")
34+ // if err != nil {
35+ // // Handle validation error
36+ // }
37+ //
38+ // // Perform arithmetic operations
39+ // tax, err := measurement.NewMoney(decimal.NewFromFloat(8.50), "USD")
40+ // if err != nil {
41+ // // Handle validation error
42+ // }
43+ // total, err := money.Add(tax)
44+ // if err != nil {
45+ // // Handle error (e.g., currency mismatch)
46+ // }
47+ //
48+ // // Create a percentage
49+ // discount, err := measurement.NewPercentage(15.0)
50+ // if err != nil {
51+ // // Handle validation error
52+ // }
53+ //
54+ // // Create a temperature
55+ // temp, err := measurement.NewTemperature(22.5, "C")
56+ // if err != nil {
57+ // // Handle validation error
58+ // }
59+ // fahrenheit := temp.ToFahrenheit()
60+ //
61+ // All value objects in this package are designed to be immutable, so they cannot
62+ // be changed after creation. To modify a value object, create a new instance with
63+ // the desired values.
64+ package measurement
0 commit comments