| 1 | package Net::YahooMessenger::Buddy; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use constant IM_AVAILABLE => 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use constant BE_RIGHT_BACK => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use constant BUSY => 2; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use constant NOT_AT_HOME => 3; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use constant NOT_AT_MY_DESK => 4; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use constant NOT_IN_THE_OFFICE => 5; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use constant ON_THE_PHONE => 6; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use constant ON_VACATION => 7; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use constant OUT_TO_LUNCH => 8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use constant STEPPED_OUT => 9; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use constant CUSTOM_STATUS => 99; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use constant SLEEP => 999; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use constant ICON_AVAILABLE => 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use constant ICON_BUSY => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use constant ICON_SLEEP => 2; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use constant STATUS_MESSAGE => [ | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | "I'm Available", | ||||||||||||||||||||||||||||
| 23 | 'Be Right Back', | ||||||||||||||||||||||||||||
| 24 | 'Busy', | ||||||||||||||||||||||||||||
| 25 | 'Not At Home', | ||||||||||||||||||||||||||||
| 26 | 'Not At My Desk', | ||||||||||||||||||||||||||||
| 27 | 'Not In The Office', | ||||||||||||||||||||||||||||
| 28 | 'On The Phone', | ||||||||||||||||||||||||||||
| 29 | 'On Vacation', | ||||||||||||||||||||||||||||
| 30 | 'Out To Lunch', | ||||||||||||||||||||||||||||
| 31 | 'Stepped Out', | ||||||||||||||||||||||||||||
| 32 | 1 | ]; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1 | ▶ | use constant IS_ONLINE => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | use constant IS_OFFLINE => 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 38 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 39 | 0 | bless { | |||||||||||||||||||||||||||
| 40 | name => 'nobody', | ||||||||||||||||||||||||||||
| 41 | status => IM_AVAILABLE, | ||||||||||||||||||||||||||||
| 42 | custom_status => '', | ||||||||||||||||||||||||||||
| 43 | busy => ICON_AVAILABLE, | ||||||||||||||||||||||||||||
| 44 | online => IS_OFFLINE, | ||||||||||||||||||||||||||||
| 45 | session_id => 0, | ||||||||||||||||||||||||||||
| 46 | }, $class; | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 50 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 51 | 0 | ▶ | $self->{name} = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | $self->{name}; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub status { | ||||||||||||||||||||||||||
|
Subroutine
status: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | $self->{status} = shift; | |||||||||||||||||||||||||||
| 59 | 0 | ▶ | $self->busy(ICON_BUSY) if $self->{status} <= STEPPED_OUT; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $self->busy(ICON_SLEEP) if $self->{status} == SLEEP; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | $self->busy(ICON_AVAILABLE) | ||||||||||||||||||||||||||||
| 62 | if $self->{status} == CUSTOM_STATUS | ||||||||||||||||||||||||||||
| 63 | 0 | ▶ | || $self->{status} == IM_AVAILABLE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"status"} == 99 or $self->{"status"} == 0
MC/DC0%0/2
$self->{"status"} == 99 or $self->{"status"} == 0
$self->{"status"} == 99
$self->{"status"} == 0
Truth table0%0/3
A or B
A= $self->{"status"} == 99B= $self->{"status"} == 0
| |||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 0 | $self->{status}; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub custom_status { | ||||||||||||||||||||||||||
|
Subroutine
custom_status: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | $self->{custom_status} = shift; | |||||||||||||||||||||||||||
| 72 | 0 | $self->status(CUSTOM_STATUS); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 0 | $self->{custom_status}; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub busy { | ||||||||||||||||||||||||||
|
Subroutine
busy: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 79 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 0 | $self->{busy} = shift; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | 0 | $self->{busy}; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub online { | ||||||||||||||||||||||||||
|
Subroutine
online: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 86 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 87 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 0 | $self->{online} = shift; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | 0 | $self->{online}; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub session_id { | ||||||||||||||||||||||||||
|
Subroutine
session_id: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 94 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 95 | 0 | ▶ | $self->{session_id} = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 0 | $self->{session_id}; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub is_online { | ||||||||||||||||||||||||||
|
Subroutine
is_online: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 100 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 101 | 0 | $self->online; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub get_status_message { | ||||||||||||||||||||||||||
|
Subroutine
get_status_message: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 105 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 106 | 0 | ▶ | return unless $self->is_online; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ( $self->status == SLEEP ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 109 | 0 | return sprintf '%s', 'Sleep'; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | elsif ( $self->status == CUSTOM_STATUS ) { | ||||||||||||||||||||||||||||
| 112 | 0 | return sprintf '%s', $self->custom_status; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | ▶ | elsif ( $self->status >= IM_AVAILABLE && $self->status <= STEPPED_OUT ) { | |||||||||||||||||||||||||||
|
Condition0%0/3
$self->status >= 0 and $self->status <= 9
MC/DC0%0/2
$self->status >= 0 and $self->status <= 9
$self->status >= 0
$self->status <= 9
Truth table0%0/3
A and B
A= $self->status >= 0B= $self->status <= 9
| |||||||||||||||||||||||||||||
| 115 | 0 | return sprintf '%s', STATUS_MESSAGE->[ $self->status ]; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | else { | ||||||||||||||||||||||||||||
| 118 | 0 | return 'Unknown'; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub to_string { | ||||||||||||||||||||||||||
|
Subroutine
to_string: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 123 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ( $self->is_online ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | return | ||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sprintf "%s %s (%s)", | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 127 | $self->busy == ICON_AVAILABLE ? ':-)' | ||||||||||||||||||||||||||||
| 128 | : $self->busy == ICON_BUSY ? ':-@' | ||||||||||||||||||||||||||||
| 129 | : $self->busy == ICON_SLEEP ? '|-I' | ||||||||||||||||||||||||||||
| 130 | : '?', | ||||||||||||||||||||||||||||
| 131 | $self->name, | ||||||||||||||||||||||||||||
| 132 | $self->get_status_message; | ||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | else { | ||||||||||||||||||||||||||||
| 135 | 0 | return sprintf "%s %s (%s)", ' ', $self->name, 'Not online'; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 1 | 1; | |||||||||||||||||||||||||||
| 140 | __END__ | ||||||||||||||||||||||||||||