Class: Yara::Match

Inherits:
Object
  • Object
show all
Defined in:
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

- (Hash) meta

Keyed values of metadata for the match object.

Returns:

  • (Hash)

    Keyed values of metadata for the match object.



# File 'ext/yara_native/Match.c'

/* 
 * Document-method: meta
 *
 * call-seq:
 *      match.meta() -> Hash
 *
 * @return [Hash]   Keyed values of metadata for the match object.
 */
static VALUE match_meta(VALUE self) {
  match_info *mi;
  Data_Get_Struct(self, match_info, mi);
  return mi->meta;
}

- (String) namespace

The namespace for this match.

Returns:

  • (String)

    The namespace for this match.



# File 'ext/yara_native/Match.c'

/* 
 * Document-method: namespace
 *
 * call-seq:
 *      match.namespace() -> String
 *
 * @return [String] The namespace for this match.
 */
static VALUE match_namespace(VALUE self) {
  match_info *mi;
  Data_Get_Struct(self, match_info, mi);
  return mi->namespace;
}

- (String) rule

The rule identifier string for this match.

Returns:

  • (String)

    The rule identifier string for this match.



# File 'ext/yara_native/Match.c'

/* 
 * Document-method: rule
 *
 * call-seq:
 *      match.rule() -> String
 *
 * @return [String] The rule identifier string for this match.
 */
static VALUE match_rule(VALUE self) {
  match_info *mi;
  Data_Get_Struct(self, match_info, mi);
  return mi->rule;
}

- (Yara::MatchString) strings

An array of MatchString objects for this match.

Returns:



# File 'ext/yara_native/Match.c'

/* 
 * Document-method: strings
 *
 * call-seq:
 *      match.strings() -> Array
 *
 * @return [Yara::MatchString]   An array of MatchString objects for this match.
 */
static VALUE match_strings(VALUE self) {
  match_info *mi;
  Data_Get_Struct(self, match_info, mi);
  return mi->strings;
}

- (String) tags

An array of tags for this match.

Returns:

  • (String)

    An array of tags for this match.



# File 'ext/yara_native/Match.c'

/* 
 * Document-method: tags
 *
 * call-seq:
 *      match.tags() -> Array
 *
 * @return [String]   An array of tags for this match.
 */
static VALUE match_tags(VALUE self) {
  match_info *mi;
  Data_Get_Struct(self, match_info, mi);
  return mi->tags;
}

- (Object) to_hash



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