Class: Ronin::Code::SQL::Field
- Inherits:
-
Expr
- Object
- Expr
- Ronin::Code::SQL::Field
show all
- Defined in:
- lib/ronin/code/sql/field.rb
Instance Method Summary
collapse
Methods inherited from Expr
#===, #in?, #not_in?
Constructor Details
#initialize(symbols, name, prefix = nil) ⇒ Field
Returns a new instance of Field.
33
34
35
36
37
|
# File 'lib/ronin/code/sql/field.rb', line 33
def initialize(symbols,name,prefix=nil)
@symbols = symbols
@prefix = prefix
@name = name
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *arguments, &block) ⇒ Object
90
91
92
93
94
95
96
|
# File 'lib/ronin/code/sql/field.rb', line 90
def method_missing(name,*arguments,&block)
if (arguments.empty? && @prefix.nil? && block.nil?)
return field(name)
end
raise(NoMethodError,sym.id2name)
end
|
Instance Method Details
#<=>(range) ⇒ Object
64
65
66
|
# File 'lib/ronin/code/sql/field.rb', line 64
def <=>(range)
between(range.begin,range.end)
end
|
#all ⇒ Object
Also known as:
*
46
47
48
|
# File 'lib/ronin/code/sql/field.rb', line 46
def all
field('*')
end
|
#as(name) ⇒ Object
56
57
58
|
# File 'lib/ronin/code/sql/field.rb', line 56
def as(name)
As.new(self,name)
end
|
#asc ⇒ Object
68
69
70
|
# File 'lib/ronin/code/sql/field.rb', line 68
def asc
Asc.new(self)
end
|
#between(start, stop) ⇒ Object
60
61
62
|
# File 'lib/ronin/code/sql/field.rb', line 60
def between(start,stop)
Between.new(self,start,stop)
end
|
#desc ⇒ Object
72
73
74
|
# File 'lib/ronin/code/sql/field.rb', line 72
def desc
Desc.new(self)
end
|
#emit ⇒ Object
76
77
78
|
# File 'lib/ronin/code/sql/field.rb', line 76
def emit
[path.to_sym]
end
|
#field(name) ⇒ Object
39
40
41
42
43
44
|
# File 'lib/ronin/code/sql/field.rb', line 39
def field(name)
sym = @symbols.symbol("#{path}.#{name}")
sym.value ||= Field.new(@symbols,name,self)
return sym
end
|
#id ⇒ Object
52
53
54
|
# File 'lib/ronin/code/sql/field.rb', line 52
def id
field('id')
end
|