-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurrency.go
More file actions
50 lines (41 loc) · 936 Bytes
/
Copy pathcurrency.go
File metadata and controls
50 lines (41 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package moneylib
import (
"fmt"
)
type currTmp struct {
Code string `json:"code"`
Number uint `json:"number"`
Symbol string `json:"sym"`
NOD uint `json:"nod"` // Number of Decimals
}
// Currency type.
type Currency struct {
code string
number uint
symbol string
nod uint // Number of Decimals
}
// Code returns currency code.
func (c *Currency) Code() string {
return c.code
}
// Number returns currency number.
func (c *Currency) Number() uint {
return c.number
}
// Symbol returns currency symbol.
func (c *Currency) Symbol() string {
return c.symbol
}
// NOD returns currency's Number of Decimal.
func (c *Currency) NOD() uint {
return c.nod
}
func (c *Currency) String() string {
return fmt.Sprintf("Currency{%v; %v; %v; %v}",
c.code, c.number, c.symbol, c.nod)
}
func newCurrency(c *currTmp) Currency {
o := Currency{code: c.Code, number: c.Number, symbol: c.Symbol, nod: c.NOD}
return o
}