Class: BB::Converter::Formula
- Inherits:
-
Object
- Object
- BB::Converter::Formula
- Defined in:
- lib/b_b/converter/formula.rb
Constant Summary collapse
- TEMPLATE =
{ between: "%s BETWEEN %s", contains: "%s CONTAINS %s", equals: "%s = %s", gt: "%s > %s", gteq: "%s >= %s", in: "%s IN %s", is: "%s IS %s", lt: "%s < %s", lteq: "%s <= %s", match: "REGEXP_MATCH(%s, %s)", not_between: "NOT %s BETWEEN %s", not_contains: "NOT %s CONTAINS %s", not_equals: "%s <> %s", not_gt: "NOT %s > %s", not_gteq: "NOT %s >= %s", not_in: "NOT %s IN %s", not_is: "%s IS NOT %s", not_lt: "NOT %s < %s", not_lteq: "NOT %s <= %s", not_match: "NOT REGEXP_MATCH(%s, %s)" }.freeze
- OPERATORS_DICTIONARY =
{ cont: :contains, contains: :contains, eq: :equals, eql: :equals, equals: :equals, gt: :gt, gteq: :gteq, like: :contains, lt: :lt, lteq: :lteq, not_cont: :not_contains, not_contains: :not_contains, not_eq: :not_equals, not_eql: :not_equals, not_equals: :not_equals, not_gt: :not_gt, not_gteq: :not_gteq, not_like: :not_contains, not_lt: :not_lt, not_lteq: :not_lteq }.freeze
- SEARCHABLE_COLUMN_FORMAT =
/(?:(\w+)_(not_\w+)|(\w+)_(\w+))/
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(column, value, options = {}) ⇒ Formula
constructor
A new instance of Formula.
Constructor Details
#initialize(column, value, options = {}) ⇒ Formula
Returns a new instance of Formula.
54 55 56 57 58 |
# File 'lib/b_b/converter/formula.rb', line 54 def initialize(column, value, = {}) @column = format_column(column) @value = format_value(value) @options = end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
52 53 54 |
# File 'lib/b_b/converter/formula.rb', line 52 def column @column end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
52 53 54 |
# File 'lib/b_b/converter/formula.rb', line 52 def operator @operator end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
52 53 54 |
# File 'lib/b_b/converter/formula.rb', line 52 def @options end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
52 53 54 |
# File 'lib/b_b/converter/formula.rb', line 52 def value @value end |
Class Method Details
.convert(column, value, options = {}) ⇒ Object
81 82 83 |
# File 'lib/b_b/converter/formula.rb', line 81 def convert(column, value, = {}) new(column, value, ).convert end |