GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Venus::Role::Printable(3) User Contributed Perl Documentation Venus::Role::Printable(3)

Venus::Role::Printable - Printable Role

Printable Role for Perl 5

  package Example;
  use Venus::Class;
  with 'Venus::Role::Dumpable';
  with 'Venus::Role::Printable';
  attr 'test';
  sub execute {
    return [@_];
  }
  sub printer {
    return [@_];
  }
  package main;
  my $example = Example->new(test => 123);
  # $example->say;

This package provides a mechanism for outputting (printing) objects or the return value of a dispatched method call to STDOUT.

This package provides the following methods:

  print(any @data) (any)

The print method prints a stringified representation of the underlying data.

Since 0.01

print example 1
  package main;
  my $example = Example->new(test => 123);
  my $print = $example->print;
  # bless({test => 123}, 'Example')
  # 1
    
print example 2
  package main;
  my $example = Example->new(test => 123);
  my $print = $example->print('execute', 1, 2, 3);
  # [bless({test => 123}, 'Example'),1,2,3]
  # 1
    
  print_json(string | coderef $method, any @args) (any)

The print_json method prints a JSON representation of the underlying data. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.

Since 2.91

print_json example 1
  package main;
  my $example = Example->new(test => 123);
  my $print_json = $example->print_json;
  # "{\"test\": 123}"
    
print_json example 2
  package main;
  my $example = Example->new(test => 123);
  my $print_json = $example->print_json('execute');
  # "[{\"test\": 123}]"
    
  print_pretty(any @data) (any)

The print_pretty method prints a stringified human-readable representation of the underlying data.

Since 0.01

print_pretty example 1
  package main;
  my $example = Example->new(test => 123);
  my $print_pretty = $example->print_pretty;
  # bless({ test => 123 }, 'Example')
  # 1
    
print_pretty example 2
  package main;
  my $example = Example->new(test => 123);
  my $print_pretty = $example->print_pretty('execute', 1, 2, 3);
  # [
  #   bless({ test => 123 }, 'Example'),
  #   1,
  #   2,
  #   3
  # ]
  # 1
    
  print_string(string | coderef $method, any @args) (any)

The print_string method prints a string representation of the underlying data without using a dump. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.

Since 0.09

print_string example 1
  package main;
  my $example = Example->new(test => 123);
  my $print_string = $example->print_string;
  # 'Example'
  # 1
    
  print_yaml(string | coderef $method, any @args) (any)

The print_yaml method prints a YAML representation of the underlying data. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.

Since 2.91

print_yaml example 1
  package main;
  my $example = Example->new(test => 123);
  my $print_yaml = $example->print_yaml;
  # "---\ntest: 123"
    
print_yaml example 2
  package main;
  my $example = Example->new(test => 123);
  my $print_yaml = $example->print_yaml('execute');
  # "---\n- test: 123"
    

  say(any @data) (any)

The say method prints a stringified representation of the underlying data, with a trailing newline.

Since 0.01

say example 1
  package main;
  my $example = Example->new(test => 123);
  my $say = $example->say;
  # bless({test => 123}, 'Example')\n
  # 1
    
say example 2
  package main;
  my $example = Example->new(test => 123);
  my $say = $example->say;
  # [bless({test => 123}, 'Example'),1,2,3]\n
  # 1
    

  say_json(string | coderef $method, any @args) (any)

The say_json method prints a JSON representation of the underlying data. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method, with a trailing newline.

Since 2.91

say_json example 1
  package main;
  my $example = Example->new(test => 123);
  my $say_json = $example->say_json;
  # "{\"test\": 123}\n"
    
say_json example 2
  package main;
  my $example = Example->new(test => 123);
  my $say_json = $example->say_json('execute');
  # "[{\"test\": 123}]\n"
    

  say_pretty(any @data) (any)

The say_pretty method prints a stringified human-readable representation of the underlying data, with a trailing newline.

Since 0.01

say_pretty example 1
  package main;
  my $example = Example->new(test => 123);
  my $say_pretty = $example->say_pretty;
  # bless({ test => 123 }, 'Example')\n
  # 1
    
say_pretty example 2
  package main;
  my $example = Example->new(test => 123);
  my $say_pretty = $example->say_pretty;
  # [
  #   bless({ test => 123 }, 'Example'),
  #   1,
  #   2,
  #   3
  # ]\n
  # 1
    

  say_string(string | coderef $method, any @args) (any)

The say_string method prints a string representation of the underlying data without using a dump, with a trailing newline. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.

Since 0.09

say_string example 1
  package main;
  my $example = Example->new(test => 123);
  my $say_string = $example->say_string;
  # "Example\n"
  # 1
    

  say_yaml(string | coderef $method, any @args) (any)

The say_yaml method prints a YAML representation of the underlying data. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method, with a trailing newline.

Since 2.91

say_yaml example 1
  package main;
  my $example = Example->new(test => 123);
  my $say_yaml = $example->say_yaml;
  # "---\ntest: 123\n"
    
say_yaml example 2
  package main;
  my $example = Example->new(test => 123);
  my $say_yaml = $example->say_yaml('execute');
  # "---\n- test: 123\n"
    

Awncorp, "awncorp@cpan.org"

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.

2023-11-27 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.