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

#bufferObject

call-seq:

matchstring.buffer() -> String

Returns:

  • String The data matched in the buffer.



280
281
282
283
284
# File 'ext/yara_native/Match.c', line 280

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

#identifierObject Also known as: ident

call-seq:

matchstring.identifier() -> String

Returns:

  • String The identification label for the string.



252
253
254
255
256
# File 'ext/yara_native/Match.c', line 252

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

#offsetObject

call-seq:

matchstring.offset() -> Fixnum

Returns:

  • Fixnum The offset where the match occurred.



266
267
268
269
270
# File 'ext/yara_native/Match.c', line 266

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