Class: Brief::Document::Section::Mapping

Inherits:
Object
  • Object
show all
Defined in:
lib/brief/document/section/mapping.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, options = {}) ⇒ Mapping

Returns a new instance of Mapping.



3
4
5
6
7
# File 'lib/brief/document/section/mapping.rb', line 3

def initialize(title, options = {})
  @title = title
  @options = options
  @config  = {}.to_mash
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



17
18
19
# File 'lib/brief/document/section/mapping.rb', line 17

def config
  @config
end

#optionsObject (readonly)

Returns the value of attribute options.



19
20
21
# File 'lib/brief/document/section/mapping.rb', line 19

def options
  @options
end

#titleObject (readonly)

Returns the value of attribute title.



21
22
23
# File 'lib/brief/document/section/mapping.rb', line 21

def title
  @title
end

Instance Method Details

#each(*args, &_block) ⇒ Object



27
28
29
30
# File 'lib/brief/document/section/mapping.rb', line 27

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

#has(*args) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/brief/document/section/mapping.rb', line 36

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

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

  self
end

#heading(*args, &block) ⇒ Object



32
33
34
# File 'lib/brief/document/section/mapping.rb', line 32

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

#is_a(*args) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/brief/document/section/mapping.rb', line 47

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

  self
end

#selectorObject



23
24
25
# File 'lib/brief/document/section/mapping.rb', line 23

def selector
  @selector || :next
end

#selector_configObject



13
14
15
# File 'lib/brief/document/section/mapping.rb', line 13

def selector_config
  config.selectors
end

#selectorsObject



9
10
11
# File 'lib/brief/document/section/mapping.rb', line 9

def selectors
  selector_config.keys
end