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.17.14 lib/brief/document/section/mapping.rb
brief-1.17.13 lib/brief/document/section/mapping.rb
brief-1.17.12 lib/brief/document/section/mapping.rb
brief-1.17.11 lib/brief/document/section/mapping.rb
brief-1.17.10 lib/brief/document/section/mapping.rb
brief-1.17.9 lib/brief/document/section/mapping.rb
brief-1.17.8 lib/brief/document/section/mapping.rb
brief-1.17.7 lib/brief/document/section/mapping.rb
brief-1.17.5 lib/brief/document/section/mapping.rb
brief-1.17.4 lib/brief/document/section/mapping.rb
brief-1.17.3 lib/brief/document/section/mapping.rb
brief-1.17.2 lib/brief/document/section/mapping.rb
brief-1.17.1 lib/brief/document/section/mapping.rb
brief-1.17.0 lib/brief/document/section/mapping.rb
brief-1.16.2 lib/brief/document/section/mapping.rb
brief-1.16.1 lib/brief/document/section/mapping.rb
brief-1.16.0 lib/brief/document/section/mapping.rb
brief-1.15.5 lib/brief/document/section/mapping.rb
brief-1.15.4 lib/brief/document/section/mapping.rb
brief-1.15.3 lib/brief/document/section/mapping.rb