Class: SecEdgar::SecURI

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSecURI

Returns a new instance of SecURI.



67
68
69
70
71
# File 'lib/sec_edgar/sec_uri.rb', line 67

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.



5
6
7
# File 'lib/sec_edgar/sec_uri.rb', line 5

def host
  @host
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/sec_edgar/sec_uri.rb', line 5

def path
  @path
end

#query_valuesObject

Returns the value of attribute query_values.



5
6
7
# File 'lib/sec_edgar/sec_uri.rb', line 5

def query_values
  @query_values
end

#schemeObject

Returns the value of attribute scheme.



5
6
7
# File 'lib/sec_edgar/sec_uri.rb', line 5

def scheme
  @scheme
end

Class Method Details

.browse_edgar_uri(args = nil) ⇒ Object



7
8
9
# File 'lib/sec_edgar/sec_uri.rb', line 7

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

.build_with_path(path, args) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/sec_edgar/sec_uri.rb', line 23

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



11
12
13
14
15
16
17
# File 'lib/sec_edgar/sec_uri.rb', line 11

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

.ownership_display_uri(args = nil) ⇒ Object



19
20
21
# File 'lib/sec_edgar/sec_uri.rb', line 19

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

Instance Method Details

#[]=(key, value) ⇒ Object



73
74
75
76
# File 'lib/sec_edgar/sec_uri.rb', line 73

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

#output_atomObject



78
79
80
81
# File 'lib/sec_edgar/sec_uri.rb', line 78

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

#to_sObject



83
84
85
# File 'lib/sec_edgar/sec_uri.rb', line 83

def to_s
  uri.to_s
end

#to_strObject



87
88
89
# File 'lib/sec_edgar/sec_uri.rb', line 87

def to_str
  to_s
end