File: Adaptor.pm

package info (click to toggle)
libcss-perl 1.08-1%2Bnmu1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 968 kB
  • ctags: 146
  • sloc: perl: 13,716; makefile: 15
file content (118 lines) | stat: -rw-r--r-- 2,257 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package CSS::Adaptor;

$VERSION = 1.01;

use strict;
use warnings;

use Carp qw(croak confess);

sub new {
	my $class = shift;
 	my $self = bless {}, $class;
	return $self;
}

sub output_rule {
	my ($self, $rule) = @_;
	return $rule->selectors.' { '.$rule->properties." }\n" ;
}

sub output_selectors {
	my ($self, $selectors) = @_;
	return join ', ', map {$_->{name}} @{$selectors}
}

sub output_properties {
	my ($self, $properties) = @_;
	return join '; ', map {$_->{property}.": ".$_->values} @{$properties};
}

sub output_values {
	my ($self, $values) = @_;
	return join '', map {$_->{value}} @{$values};
}

1;

__END__

=head1 NAME

CSS::Adaptor - Arbitrarily map CSS data for use in another context.

=head1 SYNOPSIS

  use CSS;

  # create a CSS object with an adaptor
  my $css = new CSS({
       'adaptor' => 'CSS::Adaptor',
  });


  # load some CSS data
  $css->read_file( "my_file.css" );


  # change the adaptor
  $css->set_adaptor( "CSS::Adaptor::Pretty" );


  # output CSS object using the current adaptor
  print $css->output();
  

=head1 DESCRIPTION

This class is used by CSS to translate a CSS object to a string. This 
allows CSS data to be easily mapped into other formats.

This documentation is for people who want to write their own CSS::Adaptor
module. For usage information, see the documentation for CSS.

=head1 METHODS

=head2 CONSTRUCTOR

=over 4

=item C<new()>

Called without options.

=back

=head2 FUNCTIONS

=over 4

=item C<output_rule( $rule )>

returns a string containing a formatted CSS::Style object, passed as an object ref

=item C<output_selectors( $selectors )>

returns a string containing a formatted list of CSS::Selector objects, passed as an array ref

=item C<output_properties( $properties )>

returns a string containing a formatted list of CSS::Property objects, passed as an array ref

=item C<output_values( $values )>

returns a string containing a formatted list of CSS::Value objects, passed as an array ref

=back

=head1 AUTHORS

Copyright (C) 2001-2002, Allen Day <allenday@ucla.edu>

Copyright (C) 2003-2004, Cal Henderson <cal@iamcal.com>

=head1 SEE ALSO

L<CSS>

=cut