enum Catalog::Entry::State
Defined in:
catalog/entry.crEnum Members
-
ACTIVE =
0
-
ARCHIVED =
1
Instance Method Summary
- #active?
- #archived?
-
#to_s(io : IO)
Appends a
String
representation of this enum member to the given io. -
#to_s
Returns a
String
representation of this enum member. -
#to_yaml(builder : YAML::Nodes::Builder)
Serializes this enum member by name.
Instance Method Detail
Appends a String
representation of this enum member to the given io.
See also: #to_s
.
Returns a String
representation of this enum member.
In the case of regular enums, this is just the name of the member.
In the case of flag enums, it's the names joined by vertical bars, or "None",
if the value is zero.
If an enum's value doesn't match a member's value, the raw value is returned as a string.
Color::Red.to_s # => "Red"
IOMode::None.to_s # => "None"
(IOMode::Read | IOMode::Write).to_s # => "Read | Write"
Color.new(10).to_s # => "10"
Serializes this enum member by name.
For non-flags enums, the serialization is a YAML string. The value is the
member name (see #to_s
) transformed with String#underscore
.
enum Stages
INITIAL
SECOND_STAGE
end
Stages::INITIAL.to_yaml # => %(--- initial\n)
Stages::SECOND_STAGE.to_yaml # => %(--- second_stage\n)
For flags enums, the serialization is a YAML sequence including every flagged
member individually serialized in the same way as a member of a non-flags enum.
None
is serialized as an empty sequence, All
as a sequence containing
all members.
@[Flags]
enum Sides
LEFT
RIGHT
end
Sides::LEFT.to_yaml # => %(--- [left]\n)
(Sides::LEFT | Sides::RIGHT).to_yaml # => %(--- [left, right]\n)
Sides::All.to_yaml # => %(--- [left, right]\n)
Sides::None.to_yaml # => %(--- []\n)
ValueConverter.to_yaml
offers a different serialization strategy based on the
member value.