Class: Rgviz::AggregateColumn

Inherits:
Object
  • Object
show all
Defined in:
lib/rgviz/nodes.rb

Constant Summary collapse

Avg =
Token::Avg
Count =
Token::Count
Max =
Token::Max
Min =
Token::Min
Sum =
Token::Sum

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(function, argument) ⇒ AggregateColumn

Returns a new instance of AggregateColumn.



485
486
487
488
# File 'lib/rgviz/nodes.rb', line 485

def initialize(function, argument)
  @function = function
  @argument = argument
end

Instance Attribute Details

#argumentObject

Returns the value of attribute argument.



483
484
485
# File 'lib/rgviz/nodes.rb', line 483

def argument
  @argument
end

#functionObject

Returns the value of attribute function.



482
483
484
# File 'lib/rgviz/nodes.rb', line 482

def function
  @function
end

Instance Method Details

#accept(visitor) ⇒ Object



490
491
492
493
494
495
# File 'lib/rgviz/nodes.rb', line 490

def accept(visitor)
  if visitor.visit_aggregate_column(self)
    argument.accept visitor
  end
  visitor.end_visit_aggregate_column self
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


505
506
507
# File 'lib/rgviz/nodes.rb', line 505

def eql?(other)
  other.class == ScalarFunctionColumn && other.function == @function && other.arguments == @arguments
end

#hashObject



497
498
499
500
501
502
503
# File 'lib/rgviz/nodes.rb', line 497

def hash
  return @hash if @hash
  @hash = 1
  @hash = @hash * 31 + @function.hash
  @hash = @hash * 31 + @argument.hash
  @hash
end

#to_sObject



511
512
513
# File 'lib/rgviz/nodes.rb', line 511

def to_s
  "#{function}(#{argument})"
end