Class: Glyr::Result
- Inherits:
-
Object
show all
- Defined in:
- lib/glyr/results.rb
Direct Known Subclasses
AlbumList, AlbumReview, ArtistPhoto, Backdrops, CoverArt, GuitarTabs, ImageUrl, Lyrics, Relation, SimilarArtist, SimilarSong, Tag, TagAlbum, TagArtist, TagTitle, TextUrl, Track
Defined Under Namespace
Modules: Image, Text
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(pointer, result = nil) ⇒ Result
Returns a new instance of Result.
89
90
91
92
|
# File 'lib/glyr/results.rb', line 89
def initialize (pointer, result = nil)
@internal = pointer.is_a?(FFI::Pointer) ? C::MemCache.new(pointer) : pointer
@result = result
end
|
Class Method Details
.copy(struct) ⇒ Object
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/glyr/results.rb', line 72
def self.copy (struct) return if struct[:type] == :noidea
pointer = C.glyr_cache_copy(struct)
::Glyr.const_get(struct[:type].to_s.capitalize.gsub(/_(\w)/) { $1.upcase }).
new(pointer).tap {|data|
ObjectSpace.define_finalizer data, finalizer(pointer)
}
end
|
.finalizer(pointer) ⇒ Object
83
84
85
86
87
|
# File 'lib/glyr/results.rb', line 83
def self.finalizer (pointer) proc {
C.glyr_cache_free(pointer)
}
end
|
.wrap(struct, result) ⇒ Object
65
66
67
68
69
70
|
# File 'lib/glyr/results.rb', line 65
def self.wrap (struct, result) return if struct[:type] == :noidea
::Glyr.const_get(struct[:type].to_s.capitalize.gsub(/_(\w)/) { $1.upcase }).
new(struct, result)
end
|
Instance Method Details
#clone ⇒ Object
Also known as:
dup
94
95
96
|
# File 'lib/glyr/results.rb', line 94
def clone
self.class.copy(to_native)
end
|
#data ⇒ Object
100
101
102
|
# File 'lib/glyr/results.rb', line 100
def data
to_native[:data].typecast(:string, to_native[:size])
end
|
#md5 ⇒ Object
124
125
126
|
# File 'lib/glyr/results.rb', line 124
def md5
to_native[:md5sum]
end
|
#rating ⇒ Object
112
113
114
|
# File 'lib/glyr/results.rb', line 112
def rating
to_native[:rating]
end
|
#rating=(value) ⇒ Object
116
117
118
|
# File 'lib/glyr/results.rb', line 116
def rating= (value)
to_native[:rating] = value
end
|
#source ⇒ Object
108
109
110
|
# File 'lib/glyr/results.rb', line 108
def source
Glyr.providers[type].sources[to_native[:prov].typecast(:string)]
end
|
#to_native ⇒ Object
128
129
130
|
# File 'lib/glyr/results.rb', line 128
def to_native
@internal
end
|
#type ⇒ Object
120
121
122
|
# File 'lib/glyr/results.rb', line 120
def type
to_native[:type]
end
|
#url ⇒ Object
104
105
106
|
# File 'lib/glyr/results.rb', line 104
def url
to_native[:dsrc].typecast(:string)
end
|