Class: Hakuban::ObjectDescriptor
- Defined in:
- lib/hakuban/descriptor.rb
Instance Attribute Summary collapse
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(tags, json) ⇒ ObjectDescriptor
constructor
A new instance of ObjectDescriptor.
- #initialize_copy(original) ⇒ Object
- #inspect ⇒ Object
Methods inherited from FFIObject
#do_and_drop, #do_and_drop_or_return, #drop, #drop_lock, #drop_release, #dropped?, generate_finalizer, #with_pointer, with_pointers
Constructor Details
#initialize(tags, json) ⇒ ObjectDescriptor
Returns a new instance of ObjectDescriptor.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/hakuban/descriptor.rb', line 12 def initialize(, json) Hakuban::hakuban_initialize @json = json.freeze @tags = Set.new(.map { |tag| tag.kind_of?(TagDescriptor) ? tag : TagDescriptor.new(tag) }) FFIObject.with_pointers(@tags) { |tag_pointers| tag_pointers_array = ::FFI::MemoryPointer.new(:pointer, tag_pointers.size) tag_pointers_array.write_array_of_pointer(tag_pointers) initialize_pointer(FFI::hakuban_object_descriptor_new(JSON.dump(@json),tag_pointers.size,tag_pointers_array).unwrap,:hakuban_object_descriptor_drop,:hakuban_object_descriptor_clone) } end |
Instance Attribute Details
#json ⇒ Object (readonly)
Returns the value of attribute json.
10 11 12 |
# File 'lib/hakuban/descriptor.rb', line 10 def json @json end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
10 11 12 |
# File 'lib/hakuban/descriptor.rb', line 10 def @tags end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
42 43 44 |
# File 'lib/hakuban/descriptor.rb', line 42 def ==(other) @tags == other. and @json == other.json end |
#hash ⇒ Object
48 49 50 |
# File 'lib/hakuban/descriptor.rb', line 48 def hash [@tags.hash, @json.hash].hash end |
#initialize_copy(original) ⇒ Object
24 25 26 27 |
# File 'lib/hakuban/descriptor.rb', line 24 def initialize_copy(original) super @tags = original..map(&:clone) end |
#inspect ⇒ Object
52 53 54 |
# File 'lib/hakuban/descriptor.rb', line 52 def inspect "#<ObjectDescriptor @tags={%s}, @json=%p>"%[self..map(&:inspect).join(","), self.json] end |