Class: SecQuery::Relationship
- Inherits:
-
Object
- Object
- SecQuery::Relationship
- Defined in:
- lib/sec_query/relationship.rb
Overview
> SecQuery::Relationship
Relationships are Owner / Issuer Relationships between Entities, forged by Transactions.
Constant Summary collapse
- COLUMNS =
:name, :position, :cik
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(relationship) ⇒ Relationship
constructor
A new instance of Relationship.
Constructor Details
#initialize(relationship) ⇒ Relationship
Returns a new instance of Relationship.
11 12 13 14 15 16 17 |
# File 'lib/sec_query/relationship.rb', line 11 def initialize(relationship) COLUMNS.each do |column| instance_variable_set("@#{ column }", relationship[column]) end date = relationship[:date].split('-') @date = Time.utc(date[0], date[1], date[2].to_i) end |
Class Method Details
.find(entity) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sec_query/relationship.rb', line 19 def self.find(entity) @relationships = [] if entity[:doc] doc = entity[:doc] elsif entity[:cik] doc = Entity.document(entity[:cik])[0] end type = 'Ownership Reports for Issuers:' lines = doc.search('//table').search('//td').search("b[text()*='"+type+"']") if lines.empty? type = 'Ownership Reports from:' lines = doc.search('//table').search('//td').search("b[text()*='"+type+"']") end return false if lines.empty? relationship = {} lines = lines[0].parent.search('//table')[0].search('//tr') lines.each do |line| link = line.search('//a')[0] if link.innerHTML != 'Owner' && link.innerHTML != 'Issuer' relationship[:name] = link.innerHTML relationship[:cik] = line.search('//td')[1].search('//a').innerHTML relationship[:date] = line.search('//td')[2].innerHTML relationship[:position] = line.search('//td')[3].innerHTML @relationships << Relationship.new(relationship) end end @relationships end |
.print(relationships) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/sec_query/relationship.rb', line 52 def self.print(relationships) if relationships puts "\n\t#{ relationships[1] }\n" printf("\t%-30s %-10s %-40s %-10s\n\n", 'Entity', 'CIK', 'Position', 'Date') issuer[:relationships].each do |relationship| printf("\t%-30s %-10s %-40s %-10s\n", relationship.name, relationship.cik, relationship.position, relationship.date) end else puts 'No relationships' end end |