Class: Babeltrace2::BTValue::String

Inherits:
Babeltrace2::BTValue show all
Defined in:
lib/babeltrace2/value.rb

Constant Summary collapse

SetStatus =
BTValueStringSetStatus

Constants inherited from Babeltrace2::BTValue

ArrayAppendElementStatus, ArraySetElementByIndexStatus, IntegerSigned, IntegerUnsigned, MapExtendStatus, MapForeachEntryConstFuncStatus, MapForeachEntryConstStatus, MapForeachEntryFuncStatus, MapForeachEntryStatus, StringSetStatus, TYPE_MAP

Instance Attribute Summary

Attributes inherited from Babeltrace2::BTObject

#handle

Instance Method Summary collapse

Methods inherited from Babeltrace2::BTValue

#copy, from_handle, from_value, #get_type, #is_equal

Methods inherited from Babeltrace2::BTSharedObject

inherited

Methods inherited from Babeltrace2::BTObject

#==, #to_ptr

Constructor Details

#initialize(handle = nil, retain: true, auto_release: true, value: nil) ⇒ String

Returns a new instance of String.



385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/babeltrace2/value.rb', line 385

def initialize(handle = nil, retain: true, auto_release: true, value: nil)
  if handle
    super(handle, retain: retain, auto_release: auto_release)
  else
    handle = if value.nil?
        Babeltrace2.bt_value_string_create()
      else
        Babeltrace2.bt_value_string_create_init(value)
      end
    raise Babeltrace2.process_error if handle.null?
    super(handle)
  end
end

Instance Method Details

#getObject Also known as: value, to_s



411
412
413
# File 'lib/babeltrace2/value.rb', line 411

def get
  Babeltrace2.bt_value_string_get(@handle)
end

#set(value) ⇒ Object

Raises:

  • (TypeError)


399
400
401
402
403
404
# File 'lib/babeltrace2/value.rb', line 399

def set(value)
  raise TypeError, "value is 'nil'" if value.nil?
  res = Babeltrace2.bt_value_string_set(@handle, value)
  raise Babeltrace2.process_error(res) if res != :BT_VALUE_STRING_SET_STATUS_OK
  self
end

#value=(value) ⇒ Object



406
407
408
409
# File 'lib/babeltrace2/value.rb', line 406

def value=(value)
  set(value)
  value
end