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

#metaObject

call-seq:

match.meta() -> Hash

Returns:

  • Hash Keyed values of metadata for the match object.



238
239
240
241
242
# File 'ext/yara_native/Match.c', line 238

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

#namespaceObject

call-seq:

match.namespace() -> String

Returns:

  • String The namespace for this match.



196
197
198
199
200
# File 'ext/yara_native/Match.c', line 196

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

#ruleObject

call-seq:

match.rule() -> String

Returns:

  • String The rule identifier string for this match.



182
183
184
185
186
# File 'ext/yara_native/Match.c', line 182

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:



224
225
226
227
228
# File 'ext/yara_native/Match.c', line 224

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.



210
211
212
213
214
# File 'ext/yara_native/Match.c', line 210

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