Class: DartApi::ReportParser

Inherits:
Object
  • Object
show all
Defined in:
lib/dart_api/report_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth) ⇒ ReportParser

Returns a new instance of ReportParser.



8
9
10
# File 'lib/dart_api/report_parser.rb', line 8

def initialize(auth)
  @auth = auth
end

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth.



6
7
8
# File 'lib/dart_api/report_parser.rb', line 6

def auth
  @auth
end

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/dart_api/report_parser.rb', line 6

def code
  @code
end

#dcmt_noObject (readonly)

Returns the value of attribute dcmt_no.



6
7
8
# File 'lib/dart_api/report_parser.rb', line 6

def dcmt_no
  @dcmt_no
end

#reportsObject (readonly)

Returns the value of attribute reports.



6
7
8
# File 'lib/dart_api/report_parser.rb', line 6

def reports
  @reports
end

#rpt_noObject (readonly)

Returns the value of attribute rpt_no.



6
7
8
# File 'lib/dart_api/report_parser.rb', line 6

def rpt_no
  @rpt_no
end

Instance Method Details

#parse(code) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/dart_api/report_parser.rb', line 12

def parse(code)
  url = "http://dart.fss.or.kr/api/search.json?auth=#{auth}&fin_rpt=Y&crp_cd=#{code}&start_dt=20100101&bsn_tp=A001&page_set=100"
  @code = code
  @reports = JSON.parse(open(url).read)["list"].map do |r|
    Report.new(r)
  end
end

#report(year) ⇒ Object



20
21
22
23
24
# File 'lib/dart_api/report_parser.rb', line 20

def report(year)
  reports.find do |report|
    report.year.eql? year
  end  
end