class SecEdgar::SecURI
Attributes
host[RW]
path[RW]
query_values[RW]
scheme[RW]
Public Class Methods
browse_edgar_uri(args = nil)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
new()
click to toggle source
# File lib/sec_edgar/sec_uri.rb, line 67 def initialize self.host = 'www.sec.gov' self.scheme = 'https' self.path = 'cgi-bin' end
ownership_display_uri(args = nil)
click to toggle source
# File lib/sec_edgar/sec_uri.rb, line 19 def self.ownership_display_uri(args = nil) build_with_path('/own-disp', args) end
Private Class Methods
company_name_from_hash_args(args)
click to toggle source
# File lib/sec_edgar/sec_uri.rb, line 60 def self.company_name_from_hash_args(args) return "#{ args[:last] } #{ args[:first] }" if args[:first] && args[:last] return args[:name].gsub(/[(,?!\''"":.)]/, '') if args[:name] end
handle_hash_args(hash_arg)
click to toggle source
# File lib/sec_edgar/sec_uri.rb, line 48 def self.handle_hash_args(hash_arg) options = hash_arg if hash_arg[:symbol] || hash_arg[:cik] options[:CIK] = (hash_arg[:symbol] || hash_arg[:cik]) return options end options[:company] = company_name_from_hash_args(hash_arg) options end
handle_string_args(string_arg)
click to toggle source
# File lib/sec_edgar/sec_uri.rb, line 32 def self.handle_string_args(string_arg) options = {} begin Float(string_arg) options[:CIK] = string_arg rescue if string_arg.length <= 4 options[:CIK] = string_arg else options[:company] = string_arg.gsub(/[(,?!\''"":.)]/, '') end end options end
Public Instance Methods
[]=(key, value)
click to toggle source
# File lib/sec_edgar/sec_uri.rb, line 73 def []=(key, value) query_values[key] = value self end
output_atom()
click to toggle source
# File lib/sec_edgar/sec_uri.rb, line 78 def output_atom query_values.merge!(output: 'atom') self end
to_s()
click to toggle source
# File lib/sec_edgar/sec_uri.rb, line 83 def to_s uri.to_s end
to_str()
click to toggle source
# File lib/sec_edgar/sec_uri.rb, line 87 def to_str to_s end
Private Instance Methods
uri()
click to toggle source
# File lib/sec_edgar/sec_uri.rb, line 93 def uri Addressable::URI.new( host: host, scheme: scheme, path: path, query_values: query_values ) end