Langertha/Cost.pm

filter: Statementstmt 100% 14 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 94.4% 17 / 18 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
_build_total_usd
1.0
to_hash
1.0
CRAP 1.0
« Langertha/Input.pm ↑ Summary Langertha/Request/HTTP.pm »
1 package Langertha::Cost;
2 # ABSTRACT: Immutable value object for the monetary cost of a single LLM call
3 3 our $VERSION = '0.502';
4 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 has input_usd => ( is => 'ro', isa => 'Num', default => 0 );
7 3 has output_usd => ( is => 'ro', isa => 'Num', default => 0 );
8 3 has total_usd => ( is => 'ro', isa => 'Num', lazy => 1, builder => '_build_total_usd' );
9 3 has currency => ( is => 'ro', isa => 'Str', default => 'USD' );
10  
11 sub _build_total_usd {
12 7 ▶ my ($self) = @_;
Subroutine _build_total_usd: called CC=1 SCAR=0.0
13 7 return $self->input_usd + $self->output_usd;
14 }
15  
16 sub to_hash {
17 1 ▶ my ($self) = @_;
Subroutine to_hash: called CC=1 SCAR=0.0
Pod undocumented
18 return {
19 1 input_cost_usd => $self->input_usd + 0,
20 output_cost_usd => $self->output_usd + 0,
21 total_cost_usd => $self->total_usd + 0,
22 currency => $self->currency,
23 };
24 }
25  
26 3 __PACKAGE__->meta->make_immutable;
27 3 1;
28  
29 __END__
30  
31 =pod
32  
33 =encoding UTF-8
34  
35 =head1 NAME
36  
37 Langertha::Cost - Immutable value object for the monetary cost of a single LLM call
38  
39 =head1 VERSION
40  
41 version 0.502
42  
43 =head1 SUPPORT
44  
45 =head2 Issues
46  
47 Please report bugs and feature requests on GitHub at
48 L<https://github.com/Getty/langertha/issues>.
49  
50 =head2 IRC
51  
52 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
53  
54 =head1 CONTRIBUTING
55  
56 Contributions are welcome! Please fork the repository and submit a pull request.
57  
58 =head1 AUTHOR
59  
60 Torsten Raudssus <getty@cpan.org>
61  
62 =head1 COPYRIGHT AND LICENSE
63  
64 This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>.
65  
66 This is free software; you can redistribute it and/or modify it under
67 the same terms as the Perl 5 programming language system itself.
68  
69 =cut
« Langertha/Input.pm ↑ Summary Langertha/Request/HTTP.pm »