Class: TransactionQL::Filter
- Inherits:
-
Object
- Object
- TransactionQL::Filter
- Defined in:
- lib/transaction_ql/filter.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #any(&block) ⇒ Object
- #equal(column, other) ⇒ Object
- #greater(column, other) ⇒ Object
- #greater_eq(column, other) ⇒ Object
-
#initialize(name, &block) ⇒ Filter
constructor
A new instance of Filter.
- #invert(&block) ⇒ Object
- #match(column, regex) ⇒ Object
- #matches?(hash) ⇒ Boolean
- #smaller(column, other) ⇒ Object
- #smaller_eq(column, other) ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ Filter
Returns a new instance of Filter.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/transaction_ql/filter.rb', line 7 def initialize(name, &block) @name = name @query = All.new [] @block_depth = 0 @last_blocks = [] @timeframe = [] instance_eval(&block) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/transaction_ql/filter.rb', line 5 def name @name end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
5 6 7 |
# File 'lib/transaction_ql/filter.rb', line 5 def query @query end |
Instance Method Details
#any(&block) ⇒ Object
52 53 54 55 |
# File 'lib/transaction_ql/filter.rb', line 52 def any(&block) last_block = process_inner(&block) add_expression Any.new(last_block) end |
#equal(column, other) ⇒ Object
34 35 36 |
# File 'lib/transaction_ql/filter.rb', line 34 def equal(column, other) add_expression Equal.new(column, other) end |
#greater(column, other) ⇒ Object
26 27 28 |
# File 'lib/transaction_ql/filter.rb', line 26 def greater(column, other) add_expression Greater.new(column, other) end |
#greater_eq(column, other) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/transaction_ql/filter.rb', line 38 def greater_eq(column, other) add_expression Any.new [ Greater.new(column, other), Equal.new(column, other) ] end |
#invert(&block) ⇒ Object
57 58 59 60 |
# File 'lib/transaction_ql/filter.rb', line 57 def invert(&block) last_block = process_inner(&block) add_expression Not.new(last_block) end |
#match(column, regex) ⇒ Object
22 23 24 |
# File 'lib/transaction_ql/filter.rb', line 22 def match(column, regex) add_expression Match.new(column, regex) end |
#matches?(hash) ⇒ Boolean
18 19 20 |
# File 'lib/transaction_ql/filter.rb', line 18 def matches?(hash) @query.matches? hash end |
#smaller(column, other) ⇒ Object
30 31 32 |
# File 'lib/transaction_ql/filter.rb', line 30 def smaller(column, other) add_expression Smaller.new(column, other) end |
#smaller_eq(column, other) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/transaction_ql/filter.rb', line 45 def smaller_eq(column, other) add_expression Any.new [ Smaller.new(column, other), Equal.new(column, other) ] end |