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

NAME

Data::Object::Name

ABSTRACT

Data-Object Name Class

SYNOPSIS

  use Data::Object::Name;

  my $name;

  $name = Data::Object::Name->new('Foo/Bar');
  $name = Data::Object::Name->new('Foo::Bar');
  $name = Data::Object::Name->new('Foo__Bar');
  $name = Data::Object::Name->new('foo__bar');

  my $file = $name->file; # foo__bar
  my $package = $name->package; # Foo::Bar
  my $path = $name->path; # Foo/Bar
  my $label = $name->label; # Foo__Bar

DESCRIPTION

This package provides methods for converting name strings, e.g. package names, file names, path names, and label names, to and from each other.

METHODS

This package implements the following methods.

file

  file() : Str

The file method returns a file representation of the name.

file example
  # given FooBar::Baz

  my $file = $name->file; # foo_bar__baz

format

  format(Str $method, Str $format) : Str

The format method called the specified method and passes the result to the core "sprintf" in perlfunc function with the string representation of itself as the argument

format example
  # given Foo::Bar

  $name->format('file', '%s.t'); # foo__bar.t

  # given Foo::Bar

  $name->format('path', '%s.pm'); # Foo/Bar.pm

label

  label() : Str

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

label example
  # given Foo::Bar

  my $label = $name->label; # Foo_Bar

lookslike_a_file

  lookslike_a_file() : Bool

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

lookslike_a_file example
  # given foo_bar

  $name->lookslike_a_file; # truthy

  # given Foo/Bar

  $name->lookslike_a_file; # falsy

lookslike_a_label

  lookslike_a_label() : Bool

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

lookslike_a_label example
  # given Foo_Bar

  $name->lookslike_a_label; # truthy

  # given Foo/Bar

  $name->lookslike_a_label; # falsy

lookslike_a_package

  lookslike_a_package() : Bool

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

lookslike_a_package example
  # given Foo::Bar

  $name->lookslike_a_package; # truthy

  # given Foo/Bar

  $name->lookslike_a_package; # falsy

lookslike_a_path

  lookslike_a_path() : Bool

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

lookslike_a_path example
  # given Foo::Bar

  $name->lookslike_a_path; # falsy

  # given Foo/Bar

  $name->lookslike_a_path; # truthy

new

  new(Str $arg) : Object

The new method returns instantiates the class and returns an object.

new example
  # given $string

  my $name = Data::Object::Name->new($string);

package

  package() : Str

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

package example
  # given foo-bar__bar

  my $package = $name->package; # FooBar::Baz

path

  path() : Str

The path method returns a path representation of the name.

path example
  # given Foo::Bar

  my $path = $name->path; # Foo/Bar

CREDITS

Al Newkirk, +319

Anthony Brummett, +10

Adam Hopkins, +2

José Joaquín Atria, +1

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated here, https://github.com/iamalnewkirk/do/blob/master/LICENSE.

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues

SEE ALSO

To get the most out of this distribution, consider reading the following:

Do

Data::Object

Data::Object::Class

Data::Object::ClassHas

Data::Object::Role

Data::Object::RoleHas

Data::Object::Library