Sha256: 87161e3af45a7b20151dabcc67d98a4e54a822a8f1540119da5d7ce5a8acf285

Contents?: true

Size: 910 Bytes

Versions: 92

Compression:

Stored size: 910 Bytes

Contents

class Brief::Document::Section
  class Mapping
    def initialize(title, options = {})
      @title = title
      @options = options
      @config  = {}.to_mash
    end

    def selectors
      selector_config.keys
    end

    def selector_config
      config.selectors
    end

    attr_reader :config

    attr_reader :options

    attr_reader :title

    def selector
      @selector || :next
    end

    def each(*args, &_block)
      @selector = args.first
      self
    end

    def heading(*args, &block)
      send(:each, *args, &block)
    end

    def has(*args)
      options = args.extract_options!

      unless options.empty?
        config.selectors ||= {}
        config.selectors.merge!(selector => options)
      end

      self
    end

    def is_a(*args)
      options = args.extract_options!
      klass = args.first
      options[:is_a] = klass if klass

      self
    end
  end
end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
brief-1.11.9 lib/brief/document/section/mapping.rb
brief-1.11.8 lib/brief/document/section/mapping.rb
brief-1.11.7 lib/brief/document/section/mapping.rb
brief-1.11.6 lib/brief/document/section/mapping.rb
brief-1.11.5 lib/brief/document/section/mapping.rb
brief-1.11.4 lib/brief/document/section/mapping.rb
brief-1.11.3 lib/brief/document/section/mapping.rb
brief-1.11.2 lib/brief/document/section/mapping.rb
brief-1.11.1 lib/brief/document/section/mapping.rb
brief-1.11.0 lib/brief/document/section/mapping.rb
brief-1.10.1 lib/brief/document/section/mapping.rb
brief-1.10.0 lib/brief/document/section/mapping.rb
brief-1.9.14 lib/brief/document/section/mapping.rb
brief-1.9.13 lib/brief/document/section/mapping.rb
brief-1.9.12 lib/brief/document/section/mapping.rb
brief-1.9.11 lib/brief/document/section/mapping.rb
brief-1.9.9 lib/brief/document/section/mapping.rb
brief-1.9.8 lib/brief/document/section/mapping.rb
brief-1.9.7 lib/brief/document/section/mapping.rb
brief-1.9.6 lib/brief/document/section/mapping.rb