Sha256: 7d0639903b7db782c2c7d9e9bf14b52b39337bdb76e9b88f38443a4e7b914e8c

Contents?: true

Size: 657 Bytes

Versions: 1

Compression:

Stored size: 657 Bytes

Contents

module Nanoc2

  # Nanoc2::PageRepProxy is a proxy object for a page representation
  # (Nanoc2::PageRep).
  class PageRepProxy < Proxy

    # Requests the page representation attribute with the given name. +key+
    # can be a string or a symbol, and it can contain a trailing question mark
    # (which will be stripped).
    def [](key)
      real_key = key.to_s.sub(/\?$/, '').to_sym

      if real_key == :name
        @obj.name
      elsif real_key == :content
        @obj.content
      elsif real_key == :path
        @obj.web_path
      elsif real_key == :page
        @obj.page.to_proxy
      else
        super(key)
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc2-2.2.3 lib/nanoc2/base/proxies/page_rep_proxy.rb