Class: Hakuban::TagDescriptor

Inherits:
FFIObject show all
Defined in:
lib/hakuban/descriptor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FFIObject

#do_and_drop_or_return, #drop, #dropped?, from_ffi_pointer, generate_finalizer, #initialize_copy, #with_pointer, with_pointers

Constructor Details

#initialize(json) ⇒ TagDescriptor

Returns a new instance of TagDescriptor.



58
59
60
61
62
63
# File 'lib/hakuban/descriptor.rb', line 58

def initialize(json)
  super()
  Hakuban::hakuban_initialize
  @json = json.freeze
  initialize_pointer(FFI::hakuban_tag_descriptor_new(json.to_json).unwrap, :hakuban_tag_descriptor_drop, :hakuban_tag_descriptor_clone)
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



56
57
58
# File 'lib/hakuban/descriptor.rb', line 56

def json
  @json
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



70
71
72
# File 'lib/hakuban/descriptor.rb', line 70

def ==(other)
  @json == other.json
end

#hashObject



76
77
78
# File 'lib/hakuban/descriptor.rb', line 76

def hash
  @json.hash
end

#initialize_from_ffi_pointer(pointer) ⇒ Object



65
66
67
68
# File 'lib/hakuban/descriptor.rb', line 65

def initialize_from_ffi_pointer(pointer)
  super(pointer, :hakuban_tag_descriptor_drop,:hakuban_tag_descriptor_clone)
  @json = JSON::parse(FFI::hakuban_tag_descriptor_json(pointer).clone)
end

#inspectObject



80
81
82
# File 'lib/hakuban/descriptor.rb', line 80

def inspect
  "#<TagDescriptor @json=%p>"%[self.json]
end