Sha256: 86efa67c72548e479d091074722bfd1077265fd1163936917a8d7ddfc724847f

Contents?: true

Size: 712 Bytes

Versions: 3

Compression:

Stored size: 712 Bytes

Contents

module Diagnostics
  module Data
    class Elements < Hash

      def initialize
        self[:attributes] = []
        self[:lists]      = []
        self[:texts]      = []
        self[:tables]     = []
      end

      def attributes(format)
        elements(:attributes, format)
      end

      def lists(format)
        elements(:lists, format)
      end

      def texts(format)
        elements(:texts, format)
      end

      def tables(format)
        elements(:tables, format)
      end

    private

      def elements(key, format)
        format ? format_elements(key, format) : self[key]
      end

      def format_elements(key, format)
        self[key].map(&format)
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
diagnostics-0.0.4 lib/diagnostics/data/elements.rb
diagnostics-0.0.3 lib/diagnostics/data/elements.rb
diagnostics-0.0.2 lib/diagnostics/data/elements.rb