Class: Yara::MatchString

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

Overview

Encapsulates an individual matched string location. One or more of these will be available from a Match object.

Instance Method Summary (collapse)

Instance Method Details

- (Object) <=>(other)



39
40
41
# File 'lib/yara.rb', line 39

def <=>(other)
  self.offset <=> other.offset
end

- (String) buffer

The data matched in the buffer.

Returns:

  • (String)

    The data matched in the buffer.



# File 'ext/yara_native/Match.c'

/* 
 * Document-method: buffer
 *
 * call-seq:
 *      matchstring.buffer() -> String
 *
 * @return [String]   The data matched in the buffer.
 */
static VALUE matchstring_buffer(VALUE self) {
  match_string *ms;
  Data_Get_Struct(self, match_string, ms);
  return ms->buffer;
}

- (String) identifier Also known as: ident

The identification label for the string.

Returns:

  • (String)

    The identification label for the string.



# File 'ext/yara_native/Match.c'

/* 
 * Document-method: identifier
 *
 * call-seq:
 *      matchstring.identifier() -> String
 *
 * @return [String]   The identification label for the string.
 */
static VALUE matchstring_identifier(VALUE self) {
  match_string *ms;
  Data_Get_Struct(self, match_string, ms);
  return ms->identifier;
}

- (Fixnum) offset

The offset where the match occurred.

Returns:

  • (Fixnum)

    The offset where the match occurred.



# File 'ext/yara_native/Match.c'

/* 
 * Document-method: offset
 *
 * call-seq:
 *      matchstring.offset() -> Fixnum
 *
 * @return [Fixnum]   The offset where the match occurred.
 */
static VALUE matchstring_offset(VALUE self) {
  match_string *ms;
  Data_Get_Struct(self, match_string, ms);
  return ms->offset;
}

- (Object) to_a



43
44
45
# File 'lib/yara.rb', line 43

def to_a
  [self.offset, self.ident, self.buffer]
end

- (Object) to_hash



47
48
49
# File 'lib/yara.rb', line 47

def to_hash
  { :offset => self.offset, :identifier => self.ident, :buffer => self.buffer}
end