Sha256: 08b0ae5b4f62ffb07ac27a6255ca2ecfc7dccdcbf6df188ce9644c03d54ca1ea

Contents?: true

Size: 925 Bytes

Versions: 1

Compression:

Stored size: 925 Bytes

Contents

# frozen_string_literal: true

class StringDoc
  # Lets two or more node's attributes to be manipulated together. Used by {StringDoc::MetaNode}.
  #
  # @api private
  class MetaAttributes
    def initialize(attributes)
      @attributes = attributes
    end

    def []=(key, value)
      @attributes.each do |attributes|
        attributes[key] = value
      end
    end

    def [](key)
      @attributes[0][key]
    end

    def delete(key)
      @attributes.each do |attributes|
        attributes.delete(key)
      end
    end

    def key?(key)
      @attributes.any? { |attributes|
        attributes.key?(key)
      }
    end

    def each(&block)
      @attributes.each do |attributes|
        attributes.each(&block)
      end
    end

    # @api private
    def wrap
      @attributes.each do |attributes|
        attributes.each do |key, value|
          yield value, key
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pakyow-presenter-1.0.0.rc3 lib/string_doc/meta_attributes.rb