Sha256: fc9f92e2cb642a89e95d176789bc201e9bb14618ca55f7c8fbed9218246862b5
Contents?: true
Size: 673 Bytes
Versions: 16
Compression:
Stored size: 673 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) Hash[fields.map { |f| [f[0], parse_field(node, f[2], f[1])] }] 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
16 entries across 16 versions & 2 rubygems