8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/pdflib_mini/info_reader.rb', line 8
def info_reader(method_name, keyword, default_type)
define_method(keyword) do |*args|
optlist = args.first.is_a?(String) ? args.first : ''
options = args.last.is_a?(Hash) ? args.last : {}
result = public_send(method_name, keyword, optlist)
type = options.fetch(:as, default_type)
case type
when :raw
info_result_as_raw(result)
when :boolean
info_result_as_boolean(result)
when :string
info_result_as_string(result)
else info_result_as_handle(result, type)
end
end
if default_type == :boolean
alias_method :"#{keyword}?", keyword
end
end
|