Sha256: 7d3eba17016b67e8028c9da7234c8f64dc8eaa8fe43233440ad35f3a863ab247
Contents?: true
Size: 946 Bytes
Versions: 7
Compression:
Stored size: 946 Bytes
Contents
module Sablon module DOM # An abstract class used to setup other file handling classes class FileHandler # # extends the Model class using instance eval with a block argument def self.extend_model(model_klass, &block) model_klass.instance_eval(&block) end # All subclasses should be initialized only accepting the content # as a single argument. def initialize(content); end # Finds the maximum value of an attribute by converting it to an # integer. Non numeric portions of values are ignored. The method can # be either xpath or css, xpath being the default. def max_attribute_value(xml_node, selector, attr_name, query_method: :xpath) xml_node.send(query_method, selector).map.inject(0) do |max, node| next max unless (match = node.attr(attr_name).match(/(\d+)/)) [max, match[1].to_i].max end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems