Class: Yara::Match

Inherits:
Object
  • Object
show all
Defined in:
ext/yara_native/Match.c,
lib/yara.rb,
ext/yara_native/Match.c

Overview

Encapsulates a match object returned from Yara::Rules#scan_string or Yara::Rules#scan_file. A Match contains one or more MatchString objects.

Instance Method Summary collapse

Instance Method Details

#metaHash

call-seq:

match.meta() -> Hash

Returns:

  • (Hash)

    Keyed values of metadata for the match object.



241
242
243
244
245
# File 'ext/yara_native/Match.c', line 241

static VALUE match_meta(VALUE self) {
  match_info *mi;
  Data_Get_Struct(self, match_info, mi);
  return mi->meta;
}

#namespaceString

call-seq:

match.namespace() -> String

Returns:

  • (String)

    The namespace for this match.



199
200
201
202
203
# File 'ext/yara_native/Match.c', line 199

static VALUE match_namespace(VALUE self) {
  match_info *mi;
  Data_Get_Struct(self, match_info, mi);
  return mi->namespace;
}

#ruleString

call-seq:

match.rule() -> String

Returns:

  • (String)

    The rule identifier string for this match.



185
186
187
188
189
# File 'ext/yara_native/Match.c', line 185

static VALUE match_rule(VALUE self) {
  match_info *mi;
  Data_Get_Struct(self, match_info, mi);
  return mi->rule;
}

#stringsYara::MatchString

call-seq:

match.strings() -> Array

Returns:



227
228
229
230
231
# File 'ext/yara_native/Match.c', line 227

static VALUE match_strings(VALUE self) {
  match_info *mi;
  Data_Get_Struct(self, match_info, mi);
  return mi->strings;
}

#tagsString

call-seq:

match.tags() -> Array

Returns:

  • (String)

    An array of tags for this match.



213
214
215
216
217
# File 'ext/yara_native/Match.c', line 213

static VALUE match_tags(VALUE self) {
  match_info *mi;
  Data_Get_Struct(self, match_info, mi);
  return mi->tags;
}

#to_hashObject



25
26
27
28
29
30
31
# File 'lib/yara.rb', line 25

def to_hash
  { :rule => self.rule, 
    :namespace => self.namespace, 
    :tags => self.tags,
    :meta => self.meta,
    :strings => self.strings }
end