Class: Indis::CStringEntity

Inherits:
Entity
  • Object
show all
Defined in:
lib/indis-core/cstring_entity.rb

Instance Attribute Summary collapse

Attributes inherited from Entity

#size, #tags, #vmaddr

Instance Method Summary collapse

Methods inherited from Entity

#unmap

Constructor Details

#initialize(ofs, vmmap) ⇒ CStringEntity

Returns a new instance of CStringEntity.

Parameters:

  • ofs (Fixnum)

    virtual address

  • vmmap (Indus::VMMap)

    map of the target to load value from



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/indis-core/cstring_entity.rb', line 28

def initialize(ofs, vmmap)
  super ofs
  
  @value = ''
  addr = ofs
  begin
    c = vmmap.byte_at(addr)
    @value += c.chr
    addr += 1
  end while c != 0
  
  @size = @value.length
end

Instance Attribute Details

#valueString (readonly)

Returns the value of entity.

Returns:

  • (String)

    the value of entity



24
25
26
# File 'lib/indis-core/cstring_entity.rb', line 24

def value
  @value
end

Instance Method Details

#to_aObject



46
47
48
# File 'lib/indis-core/cstring_entity.rb', line 46

def to_a
  ['DCB', "\"#{@value[0...-1]}\",0"]
end

#to_sObject



42
43
44
# File 'lib/indis-core/cstring_entity.rb', line 42

def to_s
  "DCB\t\"#{@value[0...-1]}\",0"
end