Sha256: abe6eb9ed5e8224f736acb326a3ff0484f95d4d52720532a48176f817c583655

Contents?: true

Size: 516 Bytes

Versions: 28

Compression:

Stored size: 516 Bytes

Contents

# frozen_string_literal: true

module SlimLint
  # Holds the list of captures, providing a convenient interface for accessing
  # the values and unwrapping them on your behalf.
  class CaptureMap < Hash
    # Returns the captured value with the specified name.
    #
    # @param capture_name [Symbol]
    # @return [Object]
    def [](capture_name)
      if key?(capture_name)
        super.value
      else
        raise ArgumentError, "Capture #{capture_name.inspect} does not exist!"
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
slim_lint-0.20.1 lib/slim_lint/capture_map.rb
slim_lint-0.20.0 lib/slim_lint/capture_map.rb
slim_lint-0.19.0 lib/slim_lint/capture_map.rb
slim_lint-0.18.0 lib/slim_lint/capture_map.rb
slim_lint-0.17.1 lib/slim_lint/capture_map.rb
slim_lint-0.17.0 lib/slim_lint/capture_map.rb
slim_lint-0.16.1 lib/slim_lint/capture_map.rb
slim_lint-0.16.0 lib/slim_lint/capture_map.rb