Class: BlackStack::Appending::Result
- Inherits:
-
Object
- Object
- BlackStack::Appending::Result
- Defined in:
- lib/appending.rb
Instance Attribute Summary collapse
-
#match ⇒ Object
array of values.
Instance Method Summary collapse
-
#company_domains ⇒ Object
From a given match (with the name of its index in the first position), get the company domains.
-
#emails ⇒ Object
From a given match (with the name of its index in the first position), get the email addresses.
-
#initialize(a) ⇒ Result
constructor
A new instance of Result.
-
#phones ⇒ Object
From a given match (with the name of its index in the first position), get the phone numbers.
-
#val(field) ⇒ Object
Call value() method.
-
#value(field) ⇒ Object
From a given match (with the name of its index in the first position), get the value of a field by its name.
Constructor Details
#initialize(a) ⇒ Result
Returns a new instance of Result.
442 443 444 |
# File 'lib/appending.rb', line 442 def initialize(a) self.match = a end |
Instance Attribute Details
#match ⇒ Object
array of values. first 3 values are index name, key and row-number.
440 441 442 |
# File 'lib/appending.rb', line 440 def match @match end |
Instance Method Details
#company_domains ⇒ Object
From a given match (with the name of its index in the first position), get the company domains.
488 489 490 491 492 493 494 495 496 |
# File 'lib/appending.rb', line 488 def company_domains() keys = BlackStack::Appending.company_domain_fields ret = [] keys.each { |k| v = self.value(k) ret << v if v } ret end |
#emails ⇒ Object
From a given match (with the name of its index in the first position), get the email addresses.
466 467 468 469 470 471 472 473 474 |
# File 'lib/appending.rb', line 466 def emails() keys = BlackStack::Appending.email_fields ret = [] keys.each { |k| v = self.value(k) ret << v if v } ret end |
#phones ⇒ Object
From a given match (with the name of its index in the first position), get the phone numbers.
477 478 479 480 481 482 483 484 485 |
# File 'lib/appending.rb', line 477 def phones() keys = BlackStack::Appending.phone_fields ret = [] keys.each { |k| v = self.value(k) ret << v if v } ret end |
#val(field) ⇒ Object
Call value() method.
461 462 463 |
# File 'lib/appending.rb', line 461 def val(field) self.value(field) end |
#value(field) ⇒ Object
From a given match (with the name of its index in the first position), get the value of a field by its name.
447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/appending.rb', line 447 def value(field) # get the index_name index_name = match[0] # get the index descriptor index = BlackStack::CSVIndexer.indexes.select { |i| i.name == index_name }.first # get position of the field into the hash descriptior k = index.mapping.to_a.map { |m| m[0].to_s }.index(field.to_s) # return nil if the field is not found return nil if k.nil? # get the field value match[k+3].to_s end |