Sha256: 3e5fa98def2644c7ec3546f9e12dca477006368144145e5e9da850c7643a8b1f
Contents?: true
Size: 847 Bytes
Versions: 46
Compression:
Stored size: 847 Bytes
Contents
# frozen_string_literal: true module Aranha module Parsers module Html module Node class Base attr_reader :fields def initialize(fields) @fields = fields end def parse(node) fields.map do |f| begin [f[0], parse_field(node, f[2], f[1])] rescue StandardError => e raise StandardError, "#{e.message}\nFields: #{f}" end end.to_h end private def parse_field(node, xpath, parser_method) value_method = "#{parser_method}_value" return send(value_method, node, xpath) if respond_to?(value_method) raise "Method \"#{value_method}\" not found in #{self.class}" end end end end end end
Version data entries
46 entries across 46 versions & 2 rubygems