Class: Arrow::Slicer::EqualCondition

Inherits:
Condition
  • Object
show all
Defined in:
lib/arrow/slicer.rb

Instance Method Summary collapse

Methods inherited from Condition

#&, #^, #|

Constructor Details

#initialize(column, value) ⇒ EqualCondition

Returns a new instance of EqualCondition.



215
216
217
218
# File 'lib/arrow/slicer.rb', line 215

def initialize(column, value)
  @column = column
  @value = value
end

Instance Method Details

#!@Object



220
221
222
# File 'lib/arrow/slicer.rb', line 220

def !@
  NotEqualCondition.new(@column, @value)
end

#evaluateObject



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/arrow/slicer.rb', line 224

def evaluate
  case @value
  when nil
    raw_array = @column.collect(&:nil?)
    BooleanArray.new(raw_array)
  else
    raw_array = @column.collect do |value|
      if value.nil?
        nil
      else
        @value == value
      end
    end
    BooleanArray.new(raw_array)
  end
end