Class: DartApi::ReportParser
- Inherits:
-
Object
- Object
- DartApi::ReportParser
- Defined in:
- lib/dart_api/report_parser.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#dcmt_no ⇒ Object
readonly
Returns the value of attribute dcmt_no.
-
#reports ⇒ Object
readonly
Returns the value of attribute reports.
-
#rpt_no ⇒ Object
readonly
Returns the value of attribute rpt_no.
Instance Method Summary collapse
-
#initialize(auth) ⇒ ReportParser
constructor
A new instance of ReportParser.
- #parse(code) ⇒ Object
- #report(year) ⇒ Object
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
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
6 7 8 |
# File 'lib/dart_api/report_parser.rb', line 6 def auth @auth end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/dart_api/report_parser.rb', line 6 def code @code end |
#dcmt_no ⇒ Object (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 |
#reports ⇒ Object (readonly)
Returns the value of attribute reports.
6 7 8 |
# File 'lib/dart_api/report_parser.rb', line 6 def reports @reports end |
#rpt_no ⇒ Object (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 |