| File: | blib/lib/CSS/Ruleset.pm |
| Coverage: | 100.0% |
| line | stmt | bran | cond | sub | time | code |
|---|---|---|---|---|---|---|
| 1 | package CSS::Ruleset; | |||||
| 2 | ||||||
| 3 | 6 6 6 | 25 12 25 | use strict; | |||
| 4 | 6 6 6 | 35 11 26 | use warnings; | |||
| 5 | ||||||
| 6 | sub new { | |||||
| 7 | 39 | 105 | my ($class) = @_; | |||
| 8 | 39 | 117 | my $self = bless {}, $class; | |||
| 9 | ||||||
| 10 | 39 | 107 | $self->{selector} = ''; | |||
| 11 | 39 | 108 | $self->{selectors} = []; | |||
| 12 | 39 | 163 | $self->{declarations} = []; | |||
| 13 | ||||||
| 14 | 39 | 131 | $self->{properties} = $self->{declarations}; | |||
| 15 | ||||||
| 16 | 39 | 163 | return $self; | |||
| 17 | } | |||||
| 18 | ||||||
| 19 | sub match_selector { | |||||
| 20 | 7 | 20 | my ($self, $name) = @_; | |||
| 21 | ||||||
| 22 | 7 7 | 11 25 | for my $selector (@{$self->{selectors}}){ | |||
| 23 | ||||||
| 24 | 11 | 46 | if ($selector->{name} eq $name){ | |||
| 25 | ||||||
| 26 | 2 | 11 | return 1; | |||
| 27 | } | |||||
| 28 | } | |||||
| 29 | ||||||
| 30 | 5 | 24 | return 0; | |||
| 31 | } | |||||
| 32 | ||||||
| 33 | sub get_property_by_name { | |||||
| 34 | ||||||
| 35 | 1 | 5 | return get_declaration_by_name(@_); | |||
| 36 | } | |||||
| 37 | ||||||
| 38 | sub get_declaration_by_name { | |||||
| 39 | 3 | 9 | my ($self, $name) = @_; | |||
| 40 | ||||||
| 41 | 3 3 | 6 11 | for my $declaration (@{$self->{declarations}}){ | |||
| 42 | ||||||
| 43 | 8 | 35 | if ($declaration->{property} eq $name){ | |||
| 44 | ||||||
| 45 | 2 | 6 | return $declaration; | |||
| 46 | } | |||||
| 47 | } | |||||
| 48 | ||||||
| 49 | 1 | 4 | return undef; | |||
| 50 | } | |||||
| 51 | ||||||
| 52 | ||||||
| 53 | 1; | |||||
| 54 | ||||||