Class: Operator

Inherits:
Object
  • Object
show all
Defined in:
lib/extensions/operator.rb

Overview

Concept from dm-core

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, operator, prefix = false) ⇒ Operator

Returns a new instance of Operator.



5
6
7
8
9
# File 'lib/extensions/operator.rb', line 5

def initialize(target, operator, prefix=false)
  @target   = target.to_ga
  @operator = operator
  @prefix = prefix
end

Instance Attribute Details

#operatorObject (readonly)

Returns the value of attribute operator.



3
4
5
# File 'lib/extensions/operator.rb', line 3

def operator
  @operator
end

#prefixObject (readonly)

Returns the value of attribute prefix.



3
4
5
# File 'lib/extensions/operator.rb', line 3

def prefix
  @prefix
end

#targetObject (readonly)

Returns the value of attribute target.



3
4
5
# File 'lib/extensions/operator.rb', line 3

def target
  @target
end

Instance Method Details

#==(rhs) ⇒ Object



15
16
17
18
19
# File 'lib/extensions/operator.rb', line 15

def ==(rhs)
  target == rhs.target &&
  operator == rhs.operator &&
  prefix == rhs.prefix
end

#to_gaObject



11
12
13
# File 'lib/extensions/operator.rb', line 11

def to_ga
  @prefix ? "#{operator}#{target}" : "#{target}#{operator}"
end