Class: Piglet::Field::DirectExpression

Inherits:
Object
  • Object
show all
Includes:
Field
Defined in:
lib/piglet/field/direct_expression.rb

Constant Summary

Constants included from Field

Field::FUNCTIONS, Field::SYMBOLIC_OPERATORS

Instance Attribute Summary collapse

Attributes included from Field

#name, #predecessors, #type

Instance Method Summary collapse

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(string, predecessor) ⇒ DirectExpression

Returns a new instance of DirectExpression.



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

def initialize(string, predecessor)
  @string = string
  @predecessors = [predecessor]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



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

def method_missing(name, *args)
  if name.to_s =~ /^\w+$/ && args.empty?
    field(name)
  else
    super
  end
end

Instance Attribute Details

#stringObject (readonly)

Returns the value of attribute string.



8
9
10
# File 'lib/piglet/field/direct_expression.rb', line 8

def string
  @string
end

Instance Method Details

#to_s(inner = false) ⇒ Object



15
16
17
# File 'lib/piglet/field/direct_expression.rb', line 15

def to_s(inner=false)
  @string
end