Class: Sec::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/sec/reader.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

MONTHLY_PATH =
%q{/Archives/edgar/monthly/xbrlrss-%{year}-%{month}.xml}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Reader

Returns a new instance of Reader.



23
24
25
# File 'lib/sec/reader.rb', line 23

def initialize(attrs={})
  self.connection = Connection.new(attrs)
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



11
12
13
# File 'lib/sec/reader.rb', line 11

def connection
  @connection
end

Class Method Details

.get_monthly_index(year, month) ⇒ Object



13
14
15
16
# File 'lib/sec/reader.rb', line 13

def self.get_monthly_index(year, month)
  reader = Reader.new
  reader.get_monthly_index(year, month)
end

.get_xbrl_file(url) ⇒ Object



18
19
20
21
# File 'lib/sec/reader.rb', line 18

def self.get_xbrl_file(url)
  reader = Reader.new
  reader.get_xbrl_file(url)
end

Instance Method Details

#get_monthly_index(year, month) ⇒ Object



27
28
29
30
31
32
# File 'lib/sec/reader.rb', line 27

def get_monthly_index(year, month)
  response = connection.get(monthly_query_uri(year, month))
  Crack::XML.parse(response)
rescue => error
  raise Error, error.message
end

#get_xbrl_file(url) ⇒ Object



34
35
36
# File 'lib/sec/reader.rb', line 34

def get_xbrl_file(url)
  connection.get(uri_path(url))
end