module BanksApi module Shinsei class JsParser def self.data_for(html_body) new(html_body).data end def initialize(html_body) @html_body = html_body end def data @_data ||= setup_code. to_enum(:scan, var_assign_regex). inject({}) do |variables| name, index, value = Regexp.last_match.captures value = parse_value(value) if index variables[name] ||= [] variables[name][index.to_i] = value else variables[name] = value end variables end end private attr_reader :html_body def setup_code @_setup_code ||= html_body.lines.first. match(snippet_regex). to_a.fetch(0, "") end def snippet_regex /(?<=