Class: Yara::MatchString

Inherits:
Object
  • Object
show all
Defined in:
ext/yara_native/Match.c,
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

#<=>(other) ⇒ Object



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

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

#bufferString

call-seq:

matchstring.buffer() -> String

Returns:

  • (String)

    The data matched in the buffer.



283
284
285
286
287
# File 'ext/yara_native/Match.c', line 283

static VALUE matchstring_buffer(VALUE self) {
  match_string *ms;
  Data_Get_Struct(self, match_string, ms);
  return ms->buffer;
}

#identifierString Also known as: ident

call-seq:

matchstring.identifier() -> String

Returns:

  • (String)

    The identification label for the string.



255
256
257
258
259
# File 'ext/yara_native/Match.c', line 255

static VALUE matchstring_identifier(VALUE self) {
  match_string *ms;
  Data_Get_Struct(self, match_string, ms);
  return ms->identifier;
}

#offsetFixnum

call-seq:

matchstring.offset() -> Fixnum

Returns:

  • (Fixnum)

    The offset where the match occurred.



269
270
271
272
273
# File 'ext/yara_native/Match.c', line 269

static VALUE matchstring_offset(VALUE self) {
  match_string *ms;
  Data_Get_Struct(self, match_string, ms);
  return ms->offset;
}

#to_aObject



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

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

#to_hashObject



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

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