MetarWind constructor

MetarWind(
  1. String? code,
  2. RegExpMatch? match
)

Implementation

MetarWind(String? code, RegExpMatch? match)
    : super(
        direction: null,
        speed: null,
      ) {
  if (match == null) {
    _code = null;
  } else {
    final dir = match.namedGroup('dir');
    var spd = match.namedGroup('speed');
    var gst = match.namedGroup('gust');
    final unt = match.namedGroup('units');

    spd ??= '///';
    gst ??= '///';

    if (unt == 'MPS') {
      spd = _mps2kt(spd);
      gst = _mps2kt(gst);
    }

    _direction = Direction(dir);
    _speed = Speed(spd);
    _gust = Speed(gst);
    _code = code;
  }
}