31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/youtube_it/request/base_search.rb', line 31
def fields_to_params(fields)
return "" unless fields
fields_param = [default_fields]
if fields[:recorded]
if fields[:recorded].is_a? Range
fields_param << "entry[xs:date(yt:recorded) > xs:date('#{formatted_date(fields[:recorded].first)}') and xs:date(yt:recorded) < xs:date('#{formatted_date(fields[:recorded].last)}')]"
else
fields_param << "entry[xs:date(yt:recorded) = xs:date('#{formatted_date(fields[:recorded])}')]"
end
end
if fields[:published]
if fields[:published].is_a? Range
fields_param << "entry[xs:dateTime(published) > xs:dateTime('#{formatted_date(fields[:published].first)}T00:00:00') and xs:dateTime(published) < xs:dateTime('#{formatted_date(fields[:published].last)}T00:00:00')]"
else
fields_param << "entry[xs:date(published) = xs:date('#{formatted_date(fields[:published])}')]"
end
end
if fields[:view_count]
fields_param << "entry[yt:statistics/@viewCount > #{fields[:view_count]}]"
end
if fields[:entry]
fields_param << "entry[#{fields[:entry]}]"
end
return "&fields=#{URI.escape(fields_param.join(","))}"
end
|