Class: Hakuban::ObjectDescriptor

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tags, json) ⇒ ObjectDescriptor

Returns a new instance of ObjectDescriptor.



161
162
163
164
# File 'lib/hakuban/hakuban.rb', line 161

def initialize(tags,json)
	@tags = Set.new(tags.map { |tag| tag.kind_of?(TagDescriptor) ? tag : TagDescriptor.new(tag) })
	@json = json
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



159
160
161
# File 'lib/hakuban/hakuban.rb', line 159

def json
  @json
end

#tagsObject (readonly)

Returns the value of attribute tags.



159
160
161
# File 'lib/hakuban/hakuban.rb', line 159

def tags
  @tags
end

Class Method Details

.from_ffi(ffi) ⇒ Object



170
171
172
# File 'lib/hakuban/hakuban.rb', line 170

def self.from_ffi(ffi)
	ObjectDescriptor.new(ffi.tags.map{ |tag| TagDescriptor.new(tag) }, ffi.json)
end

Instance Method Details

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



174
175
176
# File 'lib/hakuban/hakuban.rb', line 174

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

#hashObject



180
181
182
# File 'lib/hakuban/hakuban.rb', line 180

def hash
	[@tags.hash, @json.hash].hash
end

#inspectObject



184
185
186
# File 'lib/hakuban/hakuban.rb', line 184

def inspect
	"#<ObjectDescriptor @tags={%s}, @json=%p>"%[self.tags.map(&:inspect).join(","), self.json]
end

#to_ffiObject



166
167
168
# File 'lib/hakuban/hakuban.rb', line 166

def to_ffi
	FFI::FFIObjectDescriptor.construct(@tags.map(&:json), @json)
end