Class: TheArrayComparator::Sample

Inherits:
Object
  • Object
show all
Defined in:
lib/the_array_comparator/sample.rb

Overview

class holding the data for the comparism

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = [], keywords = Set.new, exceptions = Set.new, tag = nil) ⇒ Sample

New sample

Parameters:

  • data (Array) (defaults to: [])

    ([]) the data to look for keywords

  • keywords (Set) (defaults to: Set.new)

    (Set.new) the keywords (singular values/arrays will be transformed to a set)

  • exceptions (Set) (defaults to: Set.new)

    (Set.new) the exceptions (singular values/arrays will be transformed to a set)

  • tag (String) (defaults to: nil)

    (nil) a tag to identify a sample



33
34
35
36
37
38
# File 'lib/the_array_comparator/sample.rb', line 33

def initialize(data=[],keywords=Set.new,exceptions=Set.new,tag=nil)
  @keywords = Set.new( [ *keywords ] )
  @data = *data
  @exceptions = Set.new( [ *exceptions ] )
  @tag = tag
end

Instance Attribute Details

#dataObject

test data



18
19
20
# File 'lib/the_array_comparator/sample.rb', line 18

def data
  @data
end

#exceptionsObject

exceptions from data search



18
# File 'lib/the_array_comparator/sample.rb', line 18

attr_accessor :data, :keywords, :exceptions, :tag

#keywordsObject

data used to search in other data set



18
# File 'lib/the_array_comparator/sample.rb', line 18

attr_accessor :data, :keywords, :exceptions, :tag

#tagObject

description of the probe



18
# File 'lib/the_array_comparator/sample.rb', line 18

attr_accessor :data, :keywords, :exceptions, :tag

Instance Method Details

#blank?true, false

Check if sample is blank: no values for keywords, data, exceptions, tag

Returns:

  • (true, false)

    the result of check



43
44
45
# File 'lib/the_array_comparator/sample.rb', line 43

def blank?
  @keywords.blank? and @data.blank? and @exceptions.blank? and @tag.blank?
end