Sha256: 780cec18a891a89bc1c6c74d021352868d4d40bb76a1995bc88bcc6df442b431

Contents?: true

Size: 921 Bytes

Versions: 19

Compression:

Stored size: 921 Bytes

Contents

module Lookbook
  class PreviewGroup
    include Utils

    attr_reader :name, :examples, :preview

    def initialize(name, preview, examples)
      @name = name
      @preview = preview
      @examples = examples
    end

    def id
      generate_id(lookup_path)
    end

    def path
      "#{@preview.path}/#{name}"
    end

    def label
      name.titleize
    end

    def type
      :group
    end

    def params
      examples.map(&:params).flatten.uniq { |param| param[:name] }
    end

    def display_params
      merged = {}
      examples.reverse.map do |example|
        merged.merge! example.display_params
      end
      merged
    end

    def hidden?
      false
    end

    def position
      10000
    end

    def matchers
      normalize_matchers(@preview.label, label)
    end

    def hierarchy_depth
      @preview.hierarchy_depth + 1
    end

    alias_method :lookup_path, :path
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
lookbook-0.9.8 lib/lookbook/preview_group.rb
lookbook-0.9.7 lib/lookbook/preview_group.rb
lookbook-0.9.6 lib/lookbook/preview_group.rb
lookbook-0.9.5 lib/lookbook/preview_group.rb
lookbook-0.9.4 lib/lookbook/preview_group.rb
lookbook-0.9.3 lib/lookbook/preview_group.rb
lookbook-0.9.2 lib/lookbook/preview_group.rb
lookbook-0.9.1 lib/lookbook/preview_group.rb
lookbook-0.9.0 lib/lookbook/preview_group.rb
lookbook-0.8.3 lib/lookbook/preview_group.rb
lookbook-0.8.2 lib/lookbook/preview_group.rb
lookbook-0.8.1 lib/lookbook/preview_group.rb
lookbook-0.8.0 lib/lookbook/preview_group.rb
lookbook-0.8.0.beta.0 lib/lookbook/preview_group.rb
lookbook-0.7.4 lib/lookbook/preview_group.rb
lookbook-0.7.3 lib/lookbook/preview_group.rb
lookbook-0.7.2 lib/lookbook/preview_group.rb
lookbook-0.7.2.beta.5 lib/lookbook/preview_group.rb
lookbook-0.7.2.beta.4 lib/lookbook/preview_group.rb