]>
iEval git - www-backpacktf.git/blob - lib/WWW/BackpackTF/Currency.pm
1 package WWW
::BackpackTF
::Currency
;
6 our $VERSION = '0.002001';
9 my ($class, $name, $content) = @_;
10 $content->{name
} = $name;
11 bless $content, $class
14 sub name
{ shift->{name
} }
15 sub quality
{ shift->{quality
} }
16 sub priceindex
{ shift->{priceindex
}}
17 sub single
{ shift->{single
} }
18 sub plural
{ shift->{plural
} }
19 sub round
{ shift->{round
} }
20 sub craftable
{ shift->{craftable
} eq 'Craftable' }
21 sub tradable
{ shift->{tradable
} eq 'Tradable' }
22 sub defindex
{ shift->{defindex
} }
24 sub quality_name
{ WWW
::BackpackTF
::QUALITIES
->[shift->{quality
}] }
27 my $round = $self->round;
28 $nr = sprintf "%.${round}f", $nr;
29 my $suf = $nr == 1 ?
$self->single : $self->plural;
40 WWW::BackpackTF::Currency - Class representing currency information
44 my @currencies = $bp->get_currencies;
45 my $currency = $currencies[0];
46 say 'Name: ', $currency->name;
47 say 'Quality (number): ', $currency->quality;
48 say 'Quality (human-readable): ', $currency->quality_name;
49 say 'Priceindex: ', $currency->priceindex;
50 say 'Craftable: ', ($currency->craftable ? 'YES' : 'NO');
51 say 'Tradable: ', ($currency->tradable ? 'YES' : 'NO');
52 say 'Singular form: ', $currency->single;
53 say 'Plural form: ', $currency->plural;
54 say 'Round to this many decimal places: ', $currency->round;
55 say 'Defindex: ', $currency->defindex;
56 say '3.15271 units of this currency is: ', $currency->stringify(3.15271); # example return values: "3.15 keys", "3.15 ref", "3.15 buds"
60 WWW::BackpackTF::Currency is a class representing information about a currency.
68 The name of the currency.
72 The quality integer of the currency. Usually 6 (corresponding to the Unique quality).
76 The quality of the currency as a human-readable string. Usually 'Unique'.
80 The priceindex of a currency. Indicates a crate series or unusual effect. Usually 0.
84 True if the currency is craftable, false otherwise. Usually true.
88 True if the currency is tradable, false otherwise. Usually true.
92 The singular form of the currency.
96 The plural form of the currency.
100 The number of decimal places this currency should be rounded to.
104 The definition index of the currency.
106 =item B<stringify>(I<$count>)
108 Rounds I<$count> to the number of decimal places returned by B<round>, then appends a space and the correct singular/plural form of the currency.
114 L<http://backpack.tf/api/currencies>
118 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
120 =head1 COPYRIGHT AND LICENSE
122 Copyright (C) 2014-2017 by Marius Gavrilescu
124 This library is free software; you can redistribute it and/or modify
125 it under the same terms as Perl itself, either Perl version 5.18.2 or,
126 at your option, any later version of Perl 5 you may have available.
This page took 0.053502 seconds and 4 git commands to generate.