Class: NanDoc::Html::Tags

Inherits:
Object
  • Object
show all
Defined in:
lib/nandoc/html/tags.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTags

Returns a new instance of Tags.



4
5
6
7
# File 'lib/nandoc/html/tags.rb', line 4

def initialize
  @current = nil
  @content = []
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



9
10
11
# File 'lib/nandoc/html/tags.rb', line 9

def content
  @content
end

#currentObject (readonly)

Returns the value of attribute current.



10
11
12
# File 'lib/nandoc/html/tags.rb', line 10

def current
  @current
end

Instance Method Details

#push_raw(str) ⇒ Object



12
13
14
15
# File 'lib/nandoc/html/tags.rb', line 12

def push_raw str
  flush if @current
  @content.push str
end

#push_smart(name, classes, content) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/nandoc/html/tags.rb', line 17

def push_smart name, classes, content
  tag = normalize_tag(name, classes)
  if @current != tag
    flush if @current
    @current = tag
    @content.push render_open_tag(tag)
  end
  @content.push content
  nil
end

#push_tag_now(name, classes, content) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/nandoc/html/tags.rb', line 28

def push_tag_now name, classes, content
  tag = normalize_tag(name, classes)
  @content.push render_open_tag(tag)
  @content.push content
  @content.push render_close_tag(tag)
  nil
end

#to_htmlObject



36
37
38
39
# File 'lib/nandoc/html/tags.rb', line 36

def to_html
  flush if @current
  @content.join('')
end