Class: Piglet::Field::PrefixExpression

Inherits:
Object
  • Object
show all
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

Attributes included from Field

#name, #type

Instance Method Summary collapse

Methods included from Field

#and, #as, #cast, #diff, #empty?, #matches, #ne, #neg, #not, #not_null?, #null?, #or

Constructor Details

#initialize(operator, expression, space_between = true, options = nil) ⇒ PrefixExpression

Returns a new instance of PrefixExpression.



10
11
12
13
14
# File 'lib/piglet/field/prefix_expression.rb', line 10

def initialize(operator, expression, space_between=true, options=nil)
  options ||= {}
  @operator, @expression, @space_between = operator, expression, space_between
  @type = options[:type] || expression.type
end

Instance Attribute Details

#operatorObject (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

Returns:

  • (Boolean)


16
17
18
# File 'lib/piglet/field/prefix_expression.rb', line 16

def simple?
  false
end

#to_sObject



20
21
22
23
24
25
26
# File 'lib/piglet/field/prefix_expression.rb', line 20

def to_s
  if @space_between
    "#{@operator} #{parenthesise(@expression)}"
  else
    "#{@operator}#{parenthesise(@expression)}"
  end
end