Test::AskAnExpert::Question - Data wrapper for Test::AskAnExpert questions
This object provides basic semantics and data encapsulation for Test::AskAnExpert questions, feel free to subclass it as you need when writing Interfaces.
use Test::AskAnExpert::Question; $Qobj = Test::AskAnExpert::Question->new(question => "I can has cheesburger?", name => "Cheesburger", id => "Uniq123"); $Qobj->skip("The person being asked doesn't know how to answer"); $Qobj->test; $Qobj->answer('yes','commentary or diagnostics'); ($answer,$comment) = $Qobj->answer; $answer = $Qobj->answer;
The constructor takes its params as a hash, requiring question and id and optionally taking name and skip. If skip is set it is equivalent to calling
$Qobj->skip("Reason") with all of the semantic implications (you can no longer provide an answer unless you explicitly call
Test::AskAnExpert::Question also stores any other keys given to it in the blessed hashref for the convinence of any Interface implementer who doesn't need a full subclass. These should probably be treated as private unless documented otherwise in the Interface's documentation.
This is a read only accessor for the question string provided at object construction. If you try to set question it simply ignores the pass.
question but for the constructor set ID.
Mutator for the stored test name. This value is used when answering the question for TAP output in the same way as the second parameter to
Sets the internal skip value. Once set it cannot be undefed unless you use
$Qobj->test to indicate you do indeed want to test with this Question. While a skip reason is set the object will silently reject answers submitted to it.
Indicate to the object that you're going to test it, which means it should accept an answer and clear skip.
Mutator for the object's stored answer. When setting it the first parameter must match
/yes|no/i and should reflect the answer provided by the person. If diagnostics or commentary is required it is provided in the $comment param, though this is optional.
If there is currently a reason for skipping set (either through skip or in the constructor) then answer will simply return undef and do nothing. You also cannot retrieve the answer if skip gets set.
If you want to make a custom interface for Test::AskAnExpert look at Test::AskAnExpert::Interface. If you do find the need to write something so fancy that you must also subclass this, make sure your subclass is a perfect drop-in replacement or else you'll break Test::AskAnExpert itsself.
Edgar A. Bering, <firstname.lastname@example.org>
Copyright (C) 2007 by Edgar A. Bering
This library is free software; you can redistribute it and/or modify it under the terms of the Artistic 2.0 liscence as provided in the LICENSE file of this distribution.