blob: ec3ac17077fb48dab6b27043d1a63433a761fe65 (
plain)
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
|
public struct MetadataRational {
public int numerator;
public int denominator;
public MetadataRational.invalid() {
this.numerator = -1;
this.denominator = -1;
}
public MetadataRational(int numerator, int denominator) {
this.numerator = numerator;
this.denominator = denominator;
}
private bool is_component_valid(int component) {
return (component >= 0) && (component <= 1000000);
}
public bool is_valid() {
return (is_component_valid(numerator) && is_component_valid(denominator));
}
public string to_string() {
return (is_valid()) ? ("%d/%d".printf(numerator, denominator)) : "";
}
}
|