Class: SecQuery::SecURI

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSecURI

Returns a new instance of SecURI.



82
83
84
85
86
# File 'lib/sec_query/sec_uri.rb', line 82

def initialize
  self.host = 'www.sec.gov'
  self.scheme = 'https'
  self.path = 'cgi-bin'
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



20
21
22
# File 'lib/sec_query/sec_uri.rb', line 20

def host
  @host
end

#pathObject

Returns the value of attribute path.



20
21
22
# File 'lib/sec_query/sec_uri.rb', line 20

def path
  @path
end

#query_valuesObject

Returns the value of attribute query_values.



20
21
22
# File 'lib/sec_query/sec_uri.rb', line 20

def query_values
  @query_values
end

#schemeObject

Returns the value of attribute scheme.



20
21
22
# File 'lib/sec_query/sec_uri.rb', line 20

def scheme
  @scheme
end

Class Method Details

.browse_edgar_uri(args = nil) ⇒ Object



22
23
24
# File 'lib/sec_query/sec_uri.rb', line 22

def self.browse_edgar_uri(args = nil)
  build_with_path('/browse-edgar', args)
end

.build_with_path(path, args) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/sec_query/sec_uri.rb', line 38

def self.build_with_path(path, args)
  instance = SecURI.new
  instance.path += path
  return instance if args.nil?
  options = send("handle_#{ args.class.to_s.underscore }_args", args)
  instance.query_values = options
  instance
end

.for_date(date) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/sec_query/sec_uri.rb', line 26

def self.for_date(date)
  instance = SecURI.new
  instance.host = 'www.sec.gov'
  instance.scheme = 'https'
  instance.path = "Archives/edgar/daily-index/#{ date.to_sec_uri_format }"
  instance
end

.ownership_display_uri(args = nil) ⇒ Object



34
35
36
# File 'lib/sec_query/sec_uri.rb', line 34

def self.ownership_display_uri(args = nil)
  build_with_path('/own-disp', args)
end

Instance Method Details

#[]=(key, value) ⇒ Object



88
89
90
91
# File 'lib/sec_query/sec_uri.rb', line 88

def []=(key, value)
  query_values[key] = value
  self
end

#output_atomObject



93
94
95
96
# File 'lib/sec_query/sec_uri.rb', line 93

def output_atom
  query_values.merge!(output: 'atom')
  self
end

#to_sObject



98
99
100
# File 'lib/sec_query/sec_uri.rb', line 98

def to_s
  uri.to_s
end

#to_strObject



102
103
104
# File 'lib/sec_query/sec_uri.rb', line 102

def to_str
  to_s
end