Class: Glyr::Query
- Inherits:
-
Object
- Object
- Glyr::Query
- Defined in:
- lib/glyr/query.rb
Class Method Summary collapse
Instance Method Summary collapse
- #album(value) ⇒ Object
- #allowed_formats(*formats) ⇒ Object
- #artist(value) ⇒ Object
- #download! ⇒ Object
- #force_utf8! ⇒ Object
- #from(*providers) ⇒ Object
- #fuzzyness(value) ⇒ Object
- #get ⇒ Object
-
#initialize(pointer, options = {}) ⇒ Query
constructor
A new instance of Query.
- #language(value) ⇒ Object
- #language_aware! ⇒ Object
- #no_download! ⇒ Object
- #no_force_utf8! ⇒ Object
- #no_language_aware! ⇒ Object
- #number(value) ⇒ Object
- #parallel(value) ⇒ Object
- #proxy(value) ⇒ Object
- #ratio(value) ⇒ Object
- #redirects(value) ⇒ Object
- #stop ⇒ Object
- #timeout(value) ⇒ Object
- #title(value) ⇒ Object
- #to_native ⇒ Object
- #type(value) ⇒ Object
- #user_agent(value) ⇒ Object
- #verbosity(value) ⇒ Object
Constructor Details
#initialize(pointer, options = {}) ⇒ Query
Returns a new instance of Query.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/glyr/query.rb', line 35 def initialize (pointer, = {}) @internal = pointer.is_a?(FFI::Pointer) ? C::Query.new(pointer) : pointer .each {|name, value| if value == true __send__ "#{name}!" elsif value == false __send__ "no_#{name}!" else __send__ name, *value end } end |
Class Method Details
.create(options = {}) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/glyr/query.rb', line 14 def self.create ( = {}) struct = C::Query.new C.glyr_query_init(struct.pointer) wrap(struct.pointer, ) end |
.finalizer(pointer) ⇒ Object
29 30 31 32 33 |
# File 'lib/glyr/query.rb', line 29 def self.finalizer (pointer) proc { C.glyr_query_destroy(pointer) } end |
.wrap(pointer, options = {}) ⇒ Object
23 24 25 26 27 |
# File 'lib/glyr/query.rb', line 23 def self.wrap (pointer, = {}) new(pointer, ).tap {|x| ObjectSpace.define_finalizer x, finalizer(pointer) } end |
Instance Method Details
#album(value) ⇒ Object
57 58 59 |
# File 'lib/glyr/query.rb', line 57 def album (value) raise_if_error C.glyr_opt_album(to_native, value) end |
#allowed_formats(*formats) ⇒ Object
105 106 107 |
# File 'lib/glyr/query.rb', line 105 def allowed_formats (*formats) raise_if_error C.glyr_opt_allowed_formats(to_native, formats.flatten.compact.uniq.join(';')) end |
#artist(value) ⇒ Object
53 54 55 |
# File 'lib/glyr/query.rb', line 53 def artist (value) raise_if_error C.glyr_opt_artist(to_native, value) end |
#download! ⇒ Object
109 110 111 |
# File 'lib/glyr/query.rb', line 109 def download! raise_if_error C.glyr_opt_download(to_native, true) end |
#force_utf8! ⇒ Object
129 130 131 |
# File 'lib/glyr/query.rb', line 129 def force_utf8! raise_if_error C.glyr_opt_force_utf8(to_native, true) end |
#from(*providers) ⇒ Object
101 102 103 |
# File 'lib/glyr/query.rb', line 101 def from (*providers) raise_if_error C.glyr_opt_from(to_native, providers.flatten.compact.uniq.join(';')) end |
#fuzzyness(value) ⇒ Object
117 118 119 |
# File 'lib/glyr/query.rb', line 117 def fuzzyness (value) raise_if_error C.glyr_opt_fuzzyness(to_native, value) end |
#get ⇒ Object
137 138 139 140 141 142 143 144 |
# File 'lib/glyr/query.rb', line 137 def get error = FFI::MemoryPointer.new :int result = C.glyr_get(to_native, error, nil) raise_if_error error.typecast(:int) Result.wrap(result) end |
#language(value) ⇒ Object
81 82 83 |
# File 'lib/glyr/query.rb', line 81 def language (value) raise_if_error C.glyr_opt_lang(to_native, value) end |
#language_aware! ⇒ Object
85 86 87 |
# File 'lib/glyr/query.rb', line 85 def language_aware! raise_if_error C.glyr_opt_lang_aware_only(to_native, true) end |
#no_download! ⇒ Object
113 114 115 |
# File 'lib/glyr/query.rb', line 113 def no_download! raise_if_error C.glyr_opt_download(to_native, false) end |
#no_force_utf8! ⇒ Object
133 134 135 |
# File 'lib/glyr/query.rb', line 133 def no_force_utf8! raise_if_error C.glyr_opt_force_utf8(to_native, false) end |
#no_language_aware! ⇒ Object
89 90 91 |
# File 'lib/glyr/query.rb', line 89 def no_language_aware! raise_if_error C.glyr_opt_lang_aware_only(to_native, false) end |
#number(value) ⇒ Object
93 94 95 |
# File 'lib/glyr/query.rb', line 93 def number (value) raise_if_error C.glyr_opt_number(to_native, value) end |
#parallel(value) ⇒ Object
65 66 67 |
# File 'lib/glyr/query.rb', line 65 def parallel (value) raise_if_error C.glyr_opt_parallel(to_native, value) end |
#proxy(value) ⇒ Object
125 126 127 |
# File 'lib/glyr/query.rb', line 125 def proxy (value) raise_if_error C.glyr_opt_proxy(to_native, value) end |
#ratio(value) ⇒ Object
121 122 123 |
# File 'lib/glyr/query.rb', line 121 def ratio (value) raise_if_error C.glyr_opt_qsratio(to_native, value) end |
#redirects(value) ⇒ Object
73 74 75 |
# File 'lib/glyr/query.rb', line 73 def redirects (value) raise_if_error C.glyr_opt_redirects(to_native, value) end |
#stop ⇒ Object
154 155 156 |
# File 'lib/glyr/query.rb', line 154 def stop C.glyr_signal_exit(to_native) end |
#timeout(value) ⇒ Object
69 70 71 |
# File 'lib/glyr/query.rb', line 69 def timeout (value) raise_if_error C.glyr_opt_timeout(to_native, value) end |
#title(value) ⇒ Object
61 62 63 |
# File 'lib/glyr/query.rb', line 61 def title (value) raise_if_error C.glyr_opt_title(to_native, value) end |
#to_native ⇒ Object
158 159 160 |
# File 'lib/glyr/query.rb', line 158 def to_native @internal end |
#type(value) ⇒ Object
49 50 51 |
# File 'lib/glyr/query.rb', line 49 def type (value) raise_if_error C.glyr_opt_type(to_native, value.is_a?(Symbol) ? value : C::GetType[value]) end |
#user_agent(value) ⇒ Object
77 78 79 |
# File 'lib/glyr/query.rb', line 77 def user_agent (value) raise_if_error C.glyr_opt_useragent(to_native, value) end |
#verbosity(value) ⇒ Object
97 98 99 |
# File 'lib/glyr/query.rb', line 97 def verbosity (value) raise_if_error C.glyr_opt_verbosity(to_native, value) end |