File: Property.pm

package info (click to toggle)
libcss-perl 1.09-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 980 kB
  • sloc: perl: 13,716; makefile: 2
file content (112 lines) | stat: -rw-r--r-- 2,128 bytes parent folder | download | duplicates (4)
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
package CSS::Property;

$VERSION = 1.02;

use strict;
use warnings;

use CSS::Value;

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

	$self->{options} = shift;

	$self->{property}	= '';
	$self->{simple_value}	= '';
	$self->{adaptor}	= 'CSS::Adaptor';

	$self->{property}	= $self->{options}->{property} if defined $self->{options}->{property};
	$self->{simple_value}	= $self->{options}->{value} if defined $self->{options}->{value};
	$self->{adaptor}	= $self->{options}->{adaptor} if defined $self->{options}->{adaptor};
	$self->{values}		= [];

	if (defined $self->{simple_value}){
		my $value_obj = new CSS::Value({
					'value'		=> $self->{simple_value},
					'adaptor'	=> $self->{adaptor},
				});
		push @{$self->{values}}, $value_obj;
	}

	return $self;
}

sub set_adaptor {
	my $self = shift;
	my $adaptor = shift;

	# set adaptor
	$self->{adaptor} = $adaptor;
}

sub values {
	my $self = shift;
	my $adaptor_obj = new $self->{adaptor};
	return $adaptor_obj->output_values($self->{values});
}

1;

__END__

=head1 NAME

CSS::Property - A property in a CSS object tree

=head1 SYNOPSIS

  use CSS;

=head1 DESCRIPTION

This module represents a property in a CSS object tree.
Read the CSS.pm pod for information about the CSS object tree.

=head1 METHODS

=head2 CONSTRUCTORS

=over 4

=item C<new()> or C<new( { ..options.. } )>

This constructor returns a new C<CSS::Property> object, with 
an optional hash of options.

  property	property name (as string)
  value		simple value string
  adaptor	adaptor to use for serialization

If the C<value> option is passed, a C<CSS::Value> object is automatically
created and added to the object's values list.

=back

=head2 ACCESSORS

=over 4

=item C<set_adaptor( 'CSS::Adaptor::Foo' )>

This method sets the current adaptor for the object.

=item C<values()>

This method is used to serialize the property's values, using the current
adaptor. It returns a string which comes from the adaptor's C<output_values()>
method.

=back

=head1 AUTHOR

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

=head1 SEE ALSO

L<CSS>, http://www.w3.org/TR/REC-CSS1

=cut