[libweasel-perl] 08/10: * Add helper method 'has_class'

Robert James Clay jame at rocasa.us
Tue Aug 15 19:16:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

jame-guest pushed a commit to tag v0.06
in repository libweasel-perl.

commit f19337f56056a0c17c17c56318fb4cf62bb79304
Author: Erik Huelsmann <ehuels at gmail.com>
Date:   Sat Aug 20 11:28:31 2016 +0200

    * Add helper method 'has_class'
---
 lib/Weasel/Element.pm | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lib/Weasel/Element.pm b/lib/Weasel/Element.pm
index 5fac30c..7685a93 100644
--- a/lib/Weasel/Element.pm
+++ b/lib/Weasel/Element.pm
@@ -127,6 +127,17 @@ sub get_text {
 }
 
 
+=item has_class
+
+=cut
+
+sub has_class {
+    my ($self, $class) = @_;
+
+    return grep { $_ eq $class }
+        split /\s+/, ($self->get_attribute('class') // '');
+}
+
 =item is_displayed
 
 Returns a boolean indicating if an element is visible (e.g.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libweasel-perl.git



More information about the Pkg-perl-cvs-commits mailing list