Class: SecEdgar::Poll
- Inherits:
-
Object
- Object
- SecEdgar::Poll
- Defined in:
- lib/sec_edgar/poll.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#local_base ⇒ Object
readonly
Returns the value of attribute local_base.
-
#quarter ⇒ Object
readonly
Returns the value of attribute quarter.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Class Method Summary collapse
Instance Method Summary collapse
- #filings ⇒ Object
- #form4s ⇒ Object
- #index ⇒ Object
-
#initialize(year = 1993, qtr = 1, client = SecEdgar::FtpClient.instance, local_base = "./assets") ⇒ Poll
constructor
A new instance of Poll.
- #local_file ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(year = 1993, qtr = 1, client = SecEdgar::FtpClient.instance, local_base = "./assets") ⇒ Poll
Returns a new instance of Poll.
37 38 39 40 41 42 |
# File 'lib/sec_edgar/poll.rb', line 37 def initialize(year = 1993, qtr = 1, client = SecEdgar::FtpClient.instance, local_base = "./assets") @client = client @year = year @quarter = qtr @local_base = local_base end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
35 36 37 |
# File 'lib/sec_edgar/poll.rb', line 35 def client @client end |
#local_base ⇒ Object (readonly)
Returns the value of attribute local_base.
35 36 37 |
# File 'lib/sec_edgar/poll.rb', line 35 def local_base @local_base end |
#quarter ⇒ Object (readonly)
Returns the value of attribute quarter.
35 36 37 |
# File 'lib/sec_edgar/poll.rb', line 35 def quarter @quarter end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
35 36 37 |
# File 'lib/sec_edgar/poll.rb', line 35 def year @year end |
Class Method Details
.all(from_year, to_year, &blk) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/sec_edgar/poll.rb', line 44 def self.all(from_year, to_year, &blk) polls_by_year(from_year, to_year).each do |poll| poll.form4s.each do |filing| blk.call(filing) end end end |
.polls_by_year(from_year, to_year) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/sec_edgar/poll.rb', line 52 def self.polls_by_year(from_year, to_year) polls = [] (from_year..to_year).each do |yr| (1..4).each do |qtr| polls << self.new(yr, qtr) end end polls end |
Instance Method Details
#filings ⇒ Object
87 88 89 90 91 |
# File 'lib/sec_edgar/poll.rb', line 87 def filings index.scrub.split("\n").select do |line| line =~ filing_regexp end end |
#form4s ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/sec_edgar/poll.rb', line 74 def form4s filings.select do |line| line =~ form4_regexp end.map do |f| begin PollFiling.new(*f.split("|"), client) rescue => e puts line raise e end end end |
#index ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/sec_edgar/poll.rb', line 66 def index unless File.exist?(local_file) puts "fetching from sec #{ to_s }..." fetch end File.read(local_file) end |
#local_file ⇒ Object
93 94 95 |
# File 'lib/sec_edgar/poll.rb', line 93 def local_file "#{ local_dir }/master.idx" end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/sec_edgar/poll.rb', line 62 def to_s "<Poll y: #{ year } q: #{ quarter }>" end |