Class: OpenSCAP::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/openscap/text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(t = nil) ⇒ Text

Returns a new instance of Text.



7
8
9
10
11
12
13
14
# File 'lib/openscap/text.rb', line 7

def initialize(t = nil)
  @raw = case t
         when FFI::Pointer
           t
         when nil
           OpenSCAP.oscap_text_new
         end
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



5
6
7
# File 'lib/openscap/text.rb', line 5

def raw
  @raw
end

Instance Method Details

#destroyObject



24
25
26
27
# File 'lib/openscap/text.rb', line 24

def destroy
  OpenSCAP.oscap_text_free(raw)
  @raw = nil
end

#textObject



20
21
22
# File 'lib/openscap/text.rb', line 20

def text
  OpenSCAP.oscap_text_get_text(@raw).force_encoding Encoding::UTF_8
end

#text=(str) ⇒ Object



16
17
18
# File 'lib/openscap/text.rb', line 16

def text=(str)
  OpenSCAP.raise! unless OpenSCAP.oscap_text_set_text(raw, str)
end