# Get built-in schemescheme=Versionian.get_scheme(:semantic)# Register custom schemeVersionian.register_scheme(:custom,MyCustomScheme.new)# Auto-detectscheme=Versionian.detect_scheme("1.2.3")
VersionIdentifier
The core model representing a version identifier.
Attributes
Attribute
Description
#raw_string
Original version string
#scheme
The scheme that parsed/built this version
#components
Array of VersionComponent objects
#comparable_array
Array used for comparison
Methods
Method
Description
#component(name)
Get a component by name
#matches_range?(range)
Check if version matches a range
#to_s
Render version as string
Class Methods
Method
Description
#build(scheme:, components:)
Build a version programmatically
VersionScheme
Abstract base class for all version schemes.
Instance Methods
Method
Description
#parse(version_string)
Parse a string into VersionIdentifier (abstract)
#render(version)
Render version to string (default: returns raw_string)
#compare_arrays(a, b)
Compare two comparable arrays
#compare(a, b)
Compare two version strings
#valid?(version_string)
Check if string is valid for this scheme
#build(**components)
Build a version from component values
Subclassing Guidelines
When creating a custom scheme, you must:
Implement #parse(version_string)
Optionally override #compare_arrays(a, b) for custom comparison logic
Optionally override #render(version) for custom rendering
VersionComponent
Represents a single component in a version.
Attributes
Attribute
Description
#name
Symbol identifying the component
#type
Component type (integer, string, enum, etc.)
#value
The parsed value
#weight
Numeric weight for comparison
#values
For enum: allowed values
#order
For enum: sort order
#definition
ComponentDefinition reference
VersionRange
Represents a version range for matching.
Constructor
# Types:# :equals - Match exact version# :before - Less than boundary# :after - Greater than or equal to boundary# :between - Inclusive rangerange=Versionian::VersionRange.new(:after,scheme,version: "1.0.0")