The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Venus::Name - Name Class

ABSTRACT

Name Class for Perl 5

SYNOPSIS

package main;

use Venus::Name;

my $name = Venus::Name->new('Foo/Bar');

# $name->package;

DESCRIPTION

This package provides methods for parsing and formatting package namespace strings.

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:

default

default() (string)

The default method returns the default value, i.e. 'Venus'.

Since 0.01

default example 1
# given: synopsis;

my $default = $name->default;

# "Venus"

dist

dist() (string)

The dist method returns a package distribution representation of the name.

Since 0.01

dist example 1
# given: synopsis;

my $dist = $name->dist;

# "Foo-Bar"

explain

explain() (string)

The explain method returns the package name and is used in stringification operations.

Since 0.01

explain example 1
# given: synopsis;

my $explain = $name->explain;

# "Foo/Bar"

file

file() (string)

The file method returns a file representation of the name.

Since 0.01

file example 1
# given: synopsis;

my $file = $name->file;

# "foo__bar"

format

format(string $method, string $format) (string)

The format method calls the specified method passing the result to the core "sprintf" function with itself as an argument. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.

Since 0.01

format example 1
# given: synopsis;

my $format = $name->format('file', '%s.t');

# "foo__bar.t"

label

label() (string)

The label method returns a label (or constant) representation of the name.

Since 0.01

label example 1
# given: synopsis;

my $label = $name->label;

# "Foo_Bar"

lookslike_a_file

lookslike_a_file() (string)

The lookslike_a_file method returns truthy if its state resembles a filename.

Since 0.01

lookslike_a_file example 1
# given: synopsis;

my $lookslike_a_file = $name->lookslike_a_file;

# ""

lookslike_a_label

lookslike_a_label() (string)

The lookslike_a_label method returns truthy if its state resembles a label (or constant).

Since 0.01

lookslike_a_label example 1
# given: synopsis;

my $lookslike_a_label = $name->lookslike_a_label;

# ""

lookslike_a_package

lookslike_a_package() (string)

The lookslike_a_package method returns truthy if its state resembles a package name.

Since 0.01

lookslike_a_package example 1
# given: synopsis;

my $lookslike_a_package = $name->lookslike_a_package;

# ""

lookslike_a_path

lookslike_a_path() (string)

The lookslike_a_path method returns truthy if its state resembles a file path.

Since 0.01

lookslike_a_path example 1
# given: synopsis;

my $lookslike_a_path = $name->lookslike_a_path;

# 1

lookslike_a_pragma

lookslike_a_pragma() (string)

The lookslike_a_pragma method returns truthy if its state resembles a pragma.

Since 0.01

lookslike_a_pragma example 1
# given: synopsis;

my $lookslike_a_pragma = $name->lookslike_a_pragma;

# ""

package

package() (string)

The package method returns a package name representation of the name given.

Since 0.01

package example 1
# given: synopsis;

my $package = $name->package;

# "Foo::Bar"

path

path() (string)

The path method returns a path representation of the name.

Since 0.01

path example 1
# given: synopsis;

my $path = $name->path;

# "Foo/Bar"

OPERATORS

This package overloads the following operators:

operation: ("")

This package overloads the "" operator.

example 1

# given: synopsis;

my $result = "$name";

# "Foo/Bar"

example 2

# given: synopsis;

my $result = "$name, $name";

# "Foo/Bar, Foo/Bar"
operation: (.)

This package overloads the . operator.

example 1

# given: synopsis;

my $package = $name . 'Baz';

# "Foo::BarBaz"
operation: (eq)

This package overloads the eq operator.

example 1

# given: synopsis;

$name eq 'Foo/Bar';

# 1

example 2

package main;

use Venus::Name;

my $name1 = Venus::Name->new('Foo\Bar');
my $name2 = Venus::Name->new('Foo\Bar');

$name1 eq $name2;

# 1
operation: (ne)

This package overloads the ne operator.

example 1

# given: synopsis;

$name ne 'Foo\Bar';

# 1

example 2

package main;

use Venus::Name;

my $name1 = Venus::Name->new('FooBar');
my $name2 = Venus::Name->new('Foo_Bar');

$name1 ne $name2;

# 1
operation: (qr)

This package overloads the qr operator.

example 1

# given: synopsis;

"Foo/Bar" =~ qr/$name/;

# 1
operation: (~~)

This package overloads the ~~ operator.

example 1

# given: synopsis;

my $result = $name ~~ 'Foo/Bar';

# 1

AUTHORS

Awncorp, awncorp@cpan.org

LICENSE

Copyright (C) 2022, Awncorp, awncorp@cpan.org.

This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.