Class: Kintone::Query
- Inherits:
-
Object
show all
- Defined in:
- lib/kintone/query.rb,
lib/kintone/query/extension.rb
Defined Under Namespace
Modules: Extention
Classes: Field
Instance Method Summary
collapse
Constructor Details
#initialize(&block) ⇒ Query
Returns a new instance of Query.
4
5
6
7
|
# File 'lib/kintone/query.rb', line 4
def initialize(&block)
@query = []
instance_eval(&block) if block_given?
end
|
Instance Method Details
15
16
17
|
# File 'lib/kintone/query.rb', line 15
def and!
@query << 'and'
end
|
#field(code) ⇒ Object
Also known as:
f
9
10
11
12
13
|
# File 'lib/kintone/query.rb', line 9
def field(code)
condition = Field.new(code)
@query << condition
condition
end
|
67
68
69
|
# File 'lib/kintone/query.rb', line 67
def inspect
to_s
end
|
#last_month ⇒ Object
43
44
45
|
# File 'lib/kintone/query.rb', line 43
def last_month
function_string('LAST_MONTH()')
end
|
#limit(count) ⇒ Object
55
56
57
|
# File 'lib/kintone/query.rb', line 55
def limit(count)
@query << "limit #{count}"
end
|
#login_user ⇒ Object
27
28
29
|
# File 'lib/kintone/query.rb', line 27
def login_user
function_string('LOGINUSER()')
end
|
31
32
33
|
# File 'lib/kintone/query.rb', line 31
def now
function_string('NOW()')
end
|
#offset(index) ⇒ Object
59
60
61
|
# File 'lib/kintone/query.rb', line 59
def offset(index)
@query << "offset #{index}"
end
|
19
20
21
|
# File 'lib/kintone/query.rb', line 19
def or!
@query << 'or'
end
|
#order_by(field, sort = :asc) ⇒ Object
51
52
53
|
# File 'lib/kintone/query.rb', line 51
def order_by(field, sort = :asc)
@query << "order by #{field} #{sort}"
end
|
#precede(&block) ⇒ Object
23
24
25
|
# File 'lib/kintone/query.rb', line 23
def precede(&block)
@query << "(#{Kintone::Query.new(&block)})" if block_given?
end
|
#this_month ⇒ Object
39
40
41
|
# File 'lib/kintone/query.rb', line 39
def this_month
function_string('THIS_MONTH()')
end
|
#this_year ⇒ Object
47
48
49
|
# File 'lib/kintone/query.rb', line 47
def this_year
function_string('THIS_YEAR()')
end
|
63
64
65
|
# File 'lib/kintone/query.rb', line 63
def to_s
@query.map(&:to_s).join(' ')
end
|
35
36
37
|
# File 'lib/kintone/query.rb', line 35
def today
function_string('TODAY()')
end
|