# Copyright (c) 2023 Yuki Kimoto
# MIT License

class Regex::ReplaceInfo {
  version_from Regex;
  
  # Fields
  has replaced_count : ro int;
  
  has match : ro Regex::Match;
  
  # Class Methods
  static method new : Regex::ReplaceInfo ($options : object[] = undef) {
    
    my $option_names = [
      "replaced_count",
      "match",
    ];
    
    Fn->check_option_names($options, $option_names);
    
    my $self = new Regex::ReplaceInfo;
    
    my $options = Hash->new($options);
    
    if ($options->exists("replaced_count")) {
      $self->{replaced_count} = $options->{"replaced_count"}->(int);
    }
    
    if ($options->exists("match")) {
      $self->{match} = $options->{"match"}->(Regex::Match);
    }
    
    return $self;
  }
  
}