Sha256: 456078f2741c21f48509aafd5eff05c5c0e020b642645c4c0180bae59e633f27

Contents?: true

Size: 770 Bytes

Versions: 9

Compression:

Stored size: 770 Bytes

Contents

module Parade
  class Metadata

    #
    # The Assignment metadata parser is a general parser that allows the ability
    # to assign a value to the specified field of the metadata. This is
    # usually used for assigning the *transition* field but could be used to set
    # the *id* in the metadata.
    #
    # @example Settings the Metadata id
    #
    #     metadata = Metadata.parse "id=unique-slide-id"
    #     metadata.id # => "unique-slide-id"
    #
    # @see Metadata
    #
    class Assignment

      def match?(term)
        term =~ /.+=.+/
      end

      def apply(term,hash)
        key, value = parse(term)
        hash[key] = value
        hash
      end

      private

      def parse(term)
        term.split('=')
      end

    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
parade-0.10.2 lib/parade/metadata/assignment.rb
parade-0.10.1 lib/parade/metadata/assignment.rb
parade-0.10.0 lib/parade/metadata/assignment.rb
parade-0.9.2 lib/parade/metadata/assignment.rb
parade-0.9.1 lib/parade/metadata/assignment.rb
parade-0.9.0 lib/parade/metadata/assignment.rb
parade-0.8.2 lib/parade/metadata/assignment.rb
parade-0.8.1 lib/parade/metadata/assignment.rb
parade-0.8.0 lib/parade/metadata/assignment.rb