blob: 30d4b69589412e4eb52249c2088a7a36101cca8d [file] [log] [blame]
Chris Craikf516a622015-04-01 17:52:39 -07001<!DOCTYPE html>
2<!--
3Copyright 2015 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7
8<link rel="import" href="/core/scripting_object.html">
9
Chris Craik44c28202015-05-12 17:25:16 -070010<script>
11'use strict';
Chris Craikf516a622015-04-01 17:52:39 -070012
Chris Craik44c28202015-05-12 17:25:16 -070013tv.exportTo('tv.e.tquery', function() {
14 function Filter() {
15 tv.c.ScriptingObject.call(this);
16 }
17
18 Filter.normalizeFilterExpression = function(filterExpression) {
19 // Shortcut: naked strings and regexps can be used to match against slice
20 // titles.
21 if (filterExpression instanceof String ||
22 typeof(filterExpression) == 'string' ||
23 filterExpression instanceof RegExp) {
24 var filter = new tv.e.tquery.FilterHasTitle(filterExpression);
25 return filter;
26 }
27 return filterExpression;
28 };
29
30 Filter.prototype = {
31 __proto__: tv.c.ScriptingObject.prototype,
Chris Craikf516a622015-04-01 17:52:39 -070032
33 evaluate: function(context) {
34 throw new Error('Not implemented');
35 },
36
37 matchValue_: function(value, expected) {
38 if (expected instanceof RegExp)
39 return expected.test(value);
40 else if (expected instanceof Function)
41 return expected(value);
42 return value === expected;
Chris Craikf516a622015-04-01 17:52:39 -070043 }
Chris Craik44c28202015-05-12 17:25:16 -070044 };
45
46 return {
47 Filter: Filter
48 };
49});
50</script>