Class | Versionomy::Value |
In: |
lib/versionomy/value.rb
|
Parent: | Object |
A version number value is an ordered list of values, corresponding to an ordered list of fields defined by a schema. For example, if the schema is a simple one of the form "major.minor.tiny", then the the version number "1.4.2" would have the values [1, 4, 2] in that order, corresponding to the fields [:major, :minor, :tiny].
Version number values are comparable with other values that have an equivalent schema.
Create a value, given a hash or array of values, and a format. Both these parameters are required.
The values should either be a hash of field names and values, or an array of values that will be interpreted in field order.
You can also optionally provide default unparsing parameters for the value.
Compare this version number with the given version number. The comparison may succeed even if the two have different schemas, if the RHS can be converted to the LHS‘s format.
Compare this version number with the given version number, returning 0 if the two are value-equal, a negative number if the RHS is greater, or a positive number if the LHS is greater. The comparison may succeed even if the two have different schemas, if the RHS can be converted to the LHS‘s format.
Returns true if this version number is value-equal to the given number. This type of equality means that they are equivalent, or that it is possible to convert the RHS to the LHS‘s format, and that they would be equivalent after such a conversion has taken place. Note that this is different from the definition of eql?.
Compare this version number with the given version number. The comparison may succeed even if the two have different schemas, if the RHS can be converted to the LHS‘s format.
Returns the value of the given field, or nil if the field is not recognized. The field may be specified as a field object, field name, or field index.
Returns a new version number created by bumping the given field. The field may be specified as a field object, field name, or field index. Returns self unchanged if the field was not recognized or could not be modified.
Returns a new version number created by cloning this version number and changing the given field values.
You should pass in a hash of field names to values. These are the fields to modify; any other fields will be left alone, unless they are implicitly changed by the modifications you are making. For example, changing the :release_type on a value using the standard format, may change which fields are present in the resulting value.
You may also pass a delta hash to modify the unparse params stored in the value.
Attempts to convert this value to the given format, and returns the resulting value.
Raises Versionomy::Errors::ConversionError if the value could not be converted.
Returns true if this version number is equivalent to the given number. This type of equality means their schemas are compatible and their field values are equal. Note that this is different from the definition of ==.
Returns an array of recognized field names for this value, in field order. This is the order of the fields actually present in this value, in order from most to least significant.
Returns true if this value contains the given field, which may be specified as a field object, name, or index.
Returns a new version number created by resetting the given field. The field may be specified as a field object, field name, or field index. Returns self unchanged if the field was not recognized or could not be modified.
Returns a string representation generated by unparsing. If unparsing fails, does not raise Versionomy::Errors::UnparseError, but instead returns the string generated by inspect.
Unparse this version number and return a string.
Raises Versionomy::Errors::UnparseError if unparsing failed.
Return the unparsing parameters for this value. Returns nil if this value was not created using a parser.