mobile_nebula/lib/models/CIDR.dart

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
418 B
Dart
Raw Permalink Normal View History

2020-07-27 20:43:58 +00:00
class CIDR {
CIDR({this.ip = '', this.bits = 0});
2020-07-27 20:43:58 +00:00
String ip;
int bits;
@override
String toString() {
return '$ip/$bits';
}
String toJson() {
return toString();
}
factory CIDR.fromString(String val) {
2020-07-27 20:43:58 +00:00
final parts = val.split('/');
if (parts.length != 2) {
throw 'Invalid CIDR string';
}
return CIDR(
ip: parts[0],
bits: int.parse(parts[1]),
);
2020-07-27 20:43:58 +00:00
}
}