| 1 | package Sash::Properties; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | use Carp; | ||
| 6 | |||
| 7 | # Default the output type. | ||
| 8 | my $_output = 'tabular'; | ||
| 9 | |||
| 10 | # Allow the user to define the output type. | ||
| 11 | sub output { | ||
| 12 | my $class = shift; | ||
| 13 | my $output = shift; | ||
| 14 | |||
| 15 | my $allowed_output_formats = 'perlval|tabular|vertical'; | ||
| 16 | |||
| 17 | if ( defined $output ) { | ||
| 18 | croak "Invalid output <$output> format. Allowed output formats are $allowed_output_formats" | ||
| 19 | unless $output =~ /$allowed_output_formats/i; | ||
| 20 | |||
| 21 | $_output = lc( $output ); | ||
| 22 | } | ||
| 23 | |||
| 24 | return $_output; | ||
| 25 | } | ||
| 26 | |||
| 27 | # The following emulate constants so we can control the internal structure of | ||
| 28 | # the comparisons. | ||
| 29 | |||
| 30 | sub vertical { | ||
| 31 | return 'vertical'; | ||
| 32 | } | ||
| 33 | |||
| 34 | sub tabular { | ||
| 35 | return 'tabular'; | ||
| 36 | } | ||
| 37 | |||
| 38 | sub perlval { | ||
| 39 | return 'perlval'; | ||
| 40 | } | ||
| 41 | |||
| 42 | 1; |