The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Venus::Yaml - Yaml Class

ABSTRACT

Yaml Class for Perl 5

SYNOPSIS

  package main;

  use Venus::Yaml;

  my $yaml = Venus::Yaml->new(
    value => { name => ['Ready', 'Robot'], version => 0.12, stable => !!1, }
  );

  # $yaml->encode;

DESCRIPTION

This package provides methods for reading and writing YAML data. Note: This package requires that a suitable YAML library is installed, currently either YAML::XS 0.67+, YAML::PP::LibYAML 0.004+, or YAML::PP 0.23+. You can use the VENUS_YAML_PACKAGE environment variable to include or prioritize your preferred YAML library.

ATTRIBUTES

This package has the following attributes:

decoder

  decoder(CodeRef)

This attribute is read-write, accepts (CodeRef) values, and is optional.

encoder

  encoder(CodeRef)

This attribute is read-write, accepts (CodeRef) values, and is optional.

INHERITS

This package inherits behaviors from:

Venus::Kind::Utility

INTEGRATES

This package integrates behaviors from:

Venus::Role::Accessible

Venus::Role::Buildable

Venus::Role::Explainable

Venus::Role::Valuable

METHODS

This package provides the following methods:

decode

  decode(Str $yaml) (Any)

The decode method decodes the YAML string, sets the object value, and returns the decoded value.

Since 0.01

decode example 1
  # given: synopsis;

  my $decode = $yaml->decode("codename: ['Ready','Robot']\nstable: true");

  # { codename => ["Ready", "Robot"], stable => 1 }

encode

  encode() (Str)

The encode method encodes the objects value as a YAML string and returns the encoded string.

Since 0.01

encode example 1
  # given: synopsis;

  my $encode = $yaml->encode;

  # "---\nname:\n- Ready\n- Robot\nstable: true\nversion: 0.12\n"