class Babeltrace2::BTValue
Constants
- ArrayAppendElementStatus
- ArraySetElementByIndexStatus
- IntegerSigned
- IntegerUnsigned
- MapExtendStatus
- MapForeachEntryConstFuncStatus
- MapForeachEntryConstStatus
- MapForeachEntryFuncStatus
- MapForeachEntryStatus
- StringSetStatus
- TYPE_MAP
Public Class Methods
from_handle(handle, retain: true, auto_release: true)
click to toggle source
# File lib/babeltrace2/value.rb, line 62 def self.from_handle(handle, retain: true, auto_release: true) type = Babeltrace2.bt_value_get_type(handle) if type == :BT_VALUE_TYPE_NULL return BTValueNull.instance else clss = TYPE_MAP[type] raise "unsupported value type" unless clss handle = clss[0].new(handle) clss[1].new(handle, retain: retain, auto_release: auto_release) end end
from_value(value)
click to toggle source
# File lib/babeltrace2/value.rb, line 74 def self.from_value(value) case value when BTValue value when nil return BTValueNull.instance when false Bool.new(value: false) when true Bool.new(value: true) when ::Integer if value > (1<<63) - 1 BTValueIntegerUnsigned.new(value: value) else BTValueIntegerSigned.new(value: value) end when ::Float BTValueReal.new(value: value) when ::String BTValueString.new(value: value) when ::Array arr = BTValueArray.new value.each { |v| arr.push(v) } arr when ::Hash map = BTValueMap.new value.each { |k, v| map.insert_entry(k, v) } map else raise TypeError, "unsupported value type" end end
Public Instance Methods
copy()
click to toggle source
# File lib/babeltrace2/value.rb, line 115 def copy ptr = FFI::MemoryPointer.new(:pointer) res = Babeltrace2.bt_value_copy(@handle, ptr) raise Babeltrace2.process_error(res) if res != :BT_VALUE_COPY_STATUS_OK BTValue.from_handle(BTValueHandle.new(ptr.read_pointer), retain: false) end
get_type()
click to toggle source
# File lib/babeltrace2/value.rb, line 57 def get_type Babeltrace2.bt_value_get_type(@handle) end
Also aliased as: type
is_equal(other)
click to toggle source
# File lib/babeltrace2/value.rb, line 122 def is_equal(other) other = BTValue.from_value(other) Babeltrace2.bt_value_is_equal(@handle, other) != BT_FALSE end
Also aliased as: ==
to_s()
click to toggle source
# File lib/babeltrace2/value.rb, line 111 def to_s value.to_s end