Sha256: 7b1c548408f40a9e396b4c4af2cb5b09f9cde5f758cf3d9f2eb7aa789b611fff
Contents?: true
Size: 803 Bytes
Versions: 67
Compression:
Stored size: 803 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| [f[0], parse_field(node, f[2], f[1])] rescue StandardError => e raise StandardError, "#{e.message}\nFields: #{f}" 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
67 entries across 67 versions & 2 rubygems