Sha256: 23cf661cbb523da411142cdbbe806d3134f25f3e6657cf9d2c41e68207fa76a6

Contents?: true

Size: 542 Bytes

Versions: 9

Compression:

Stored size: 542 Bytes

Contents

module BetterHtml
  class NodeIterator
    class Base
      def self.tokenized_attribute(name)
        class_eval <<~RUBY
          attr_reader :#{name}_parts

          def #{name}
            #{name}_parts.map(&:text).join
          end
        RUBY
      end

      def node_type
        self.class.name.split('::').last.downcase.to_sym
      end

      %w(text cdata comment element).each do |name|
        class_eval <<~RUBY
          def #{name}?
            node_type == :#{name}
          end
        RUBY
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
better_html-0.0.12 lib/better_html/node_iterator/base.rb
better_html-0.0.11 lib/better_html/node_iterator/base.rb
better_html-0.0.10 lib/better_html/node_iterator/base.rb
better_html-0.0.9 lib/better_html/node_iterator/base.rb
better_html-0.0.8 lib/better_html/node_iterator/base.rb
better_html-0.0.7 lib/better_html/node_iterator/base.rb
better_html-0.0.5 lib/better_html/node_iterator/base.rb
better_html-0.0.4 lib/better_html/node_iterator/base.rb
better_html-0.0.3 lib/better_html/node_iterator/base.rb