Module: Cuprum::Cli::Coercion
- Parent Namespace
- Cuprum::Cli
- Defined In
- lib/cuprum/cli/coercion.rb
Table Of Contents
Overview
Utility for coercing raw string values to other literal types.
Back To Top
Defined Under Namespace
- Classes
- CoercionError
Back To Top
Class Methods
.coerce(value) => nil, true, false, Integer, String
Converts the value to a predicted type based on the value format.
Parameters
- value (Object) — the value to convert.
Returns
- (nil, true, false, Integer, String) — the coerced value.
.coerce_boolean(value) => true, false
Converts the value to true or false.
Parameters
- value (Object) — the value to convert.
Returns
- (true, false) — the coerced value.
Raises
- (CoercionError) — if the value cannot be coerced to either true or
false.
.coerce_boolean?(value) => true, false
Returns
- (true, false) — true if the value can be safely coerced to either
true or false, otherwise false.
.coerce_integer(value) => Integer
Converts the value to an Integer.
Parameters
- value (Object) — the value to convert.
Returns
- (Integer) — the coerced value.
Raises
- (CoercionError) — if the value cannot be coerced to an Integer.
.coerce_integer?(value) => true, false
Returns
- (true, false) — true if the value can be safely coerced to an
Integer, otherwise false.
.coerce_nil(value) => nil
Converts the value to nil.
Parameters
- value (Object) — the value to convert.
Returns
- (nil) — the coerced value.
Raises
- (CoercionError) — if the value cannot be coerced to nil.
.coerce_nil?(value) => true, false
Returns
- (true, false) — true if the value can be safely coerced to nil,
otherwise false.
Back To Top
Back to
Documentation |
Reference
|
Cuprum
|
Cuprum::Cli