Class: SecQuery::Filing

Inherits:
Object
  • Object
show all
Defined in:
lib/sec_query/filing.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filing) ⇒ Filing

Returns a new instance of Filing.



4
5
6
7
8
9
10
11
12
# File 'lib/sec_query/filing.rb', line 4

def initialize(filing)
    @cik = filing[:cik]
    @title = filing[:title]
    @summary = filing[:summary]
    @link = filing[:link]
    @term = filing[:term]
    @date = filing[:date]
    @file_id = filing[:file_id]
end

Instance Attribute Details

#cikObject

Returns the value of attribute cik.



3
4
5
# File 'lib/sec_query/filing.rb', line 3

def cik
  @cik
end

#dateObject

Returns the value of attribute date.



3
4
5
# File 'lib/sec_query/filing.rb', line 3

def date
  @date
end

#file_idObject

Returns the value of attribute file_id.



3
4
5
# File 'lib/sec_query/filing.rb', line 3

def file_id
  @file_id
end

Returns the value of attribute link.



3
4
5
# File 'lib/sec_query/filing.rb', line 3

def link
  @link
end

#summaryObject

Returns the value of attribute summary.



3
4
5
# File 'lib/sec_query/filing.rb', line 3

def summary
  @summary
end

#termObject

Returns the value of attribute term.



3
4
5
# File 'lib/sec_query/filing.rb', line 3

def term
  @term
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/sec_query/filing.rb', line 3

def title
  @title
end

Class Method Details

.find(entity, start, count, limit) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sec_query/filing.rb', line 15

def self.find(entity, start, count, limit)

    if start == nil; start = 0; end
    if count == nil; count = 80; end
    url ="http://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK="+entity[:cik]+"&output=atom&count="+count.to_s+"&start="+start.to_s
    response = Entity.query(url)
    doc = Hpricot::XML(response)
    entries = doc.search(:entry);
    query_more = false;
    for entry in entries
        query_more = true;
        filing={}
        filing[:cik] = entity[:cik]
        filing[:title] = (entry/:title).innerHTML
        filing[:summary] = (entry/:summary).innerHTML
        filing[:link] =  (entry/:link)[0].get_attribute("href")
        filing[:term] = (entry/:category)[0].get_attribute("term")
        filing[:date] = (entry/:updated).innerHTML
        filing[:file_id] = (entry/:id).innerHTML.split("=").last

        entity[:filings] << Filing.new(filing)              
    end
    if query_more and limit == nil || query_more and !limit
        Filing.find(entity, start+count, count, limit);
    else
        return entity
    end
end