Class: Piglet::Field::PrefixExpression
- Inherits:
-
Object
- Object
- Piglet::Field::PrefixExpression
- Includes:
- Field
- Defined in:
- lib/piglet/field/prefix_expression.rb
Overview
:nodoc:
Constant Summary
Constants included from Field
Field::FUNCTIONS, Field::SYMBOLIC_OPERATORS
Instance Attribute Summary collapse
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
Attributes included from Field
Instance Method Summary collapse
-
#initialize(operator, expression, space_between = true, options = nil) ⇒ PrefixExpression
constructor
A new instance of PrefixExpression.
- #simple? ⇒ Boolean
- #to_s(inner = false) ⇒ Object
Methods included from Field
#and, #as, #cast, #diff, #distinct, #empty?, #field, #field_alias, #filter, #flatten, #generate_field_alias, #get, #limit, #matches, #ne, #neg, #not, #not_null?, #null?, #or, #order, #sample
Constructor Details
#initialize(operator, expression, space_between = true, options = nil) ⇒ PrefixExpression
Returns a new instance of PrefixExpression.
10 11 12 13 14 15 |
# File 'lib/piglet/field/prefix_expression.rb', line 10 def initialize(operator, expression, space_between=true, =nil) ||= {} @operator, @expression, @space_between = operator, expression, space_between @type = [:type] || expression.type @predecessors = [expression] end |
Instance Attribute Details
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
8 9 10 |
# File 'lib/piglet/field/prefix_expression.rb', line 8 def operator @operator end |
Instance Method Details
#simple? ⇒ Boolean
17 18 19 |
# File 'lib/piglet/field/prefix_expression.rb', line 17 def simple? false end |
#to_s(inner = false) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/piglet/field/prefix_expression.rb', line 21 def to_s(inner=false) expr = if inner then @expression.field_alias else @expression end if @space_between "#{@operator} #{parenthesise(expr)}" else "#{@operator}#{parenthesise(expr)}" end end |