Class: Linkage::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/linkage/group.rb

Overview

This class represents a group of records that match based on criteria described via the Dataset#link_with method. Group’s are created by subclasses of the Runner class during execution.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matching_values) ⇒ Group

Returns a new instance of Group.

Examples:

Linkage::Group.new({:foo => 123, :bar => 'baz'})

Parameters:

  • matching_values (Hash)

    Values that define this group



18
19
20
21
# File 'lib/linkage/group.rb', line 18

def initialize(matching_values)
  @values = matching_values
  @records = []
end

Instance Attribute Details

#recordsArray<Object> (readonly)

Returns An array of this group’s record ids.

Returns:

  • (Array<Object>)

    An array of this group’s record ids



10
11
12
# File 'lib/linkage/group.rb', line 10

def records
  @records
end

#valuesHash (readonly)

Returns Hash of matching values.

Returns:

  • (Hash)

    Hash of matching values



13
14
15
# File 'lib/linkage/group.rb', line 13

def values
  @values
end

Instance Method Details

#add_record(record_id) ⇒ Object

Add a record id to this group’s set of records.

Parameters:

  • record_id (Object)


34
35
36
# File 'lib/linkage/group.rb', line 34

def add_record(record_id)
  @records << record_id
end

#countFixnum

Returns Number of records in this group.

Returns:

  • (Fixnum)

    Number of records in this group



39
40
41
# File 'lib/linkage/group.rb', line 39

def count
  @records.count
end

#matches?(values) ⇒ Boolean

Check to see if the given set of values matches this group’s values.

Parameters:

  • values (Hash)

    Hash of values

Returns:

  • (Boolean)

    true if match, false if not



27
28
29
# File 'lib/linkage/group.rb', line 27

def matches?(values)
  @values == values
end