Class: HTML::Tag

Inherits:
Object show all
Defined in:
lib/test/rails/pp_html_document.rb

Instance Method Summary collapse

Instance Method Details

#pretty_print(q) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/test/rails/pp_html_document.rb', line 26

def pretty_print(q)
  case @closing
  when :close then
    q.text "[close #{@name}]"
  when :self then
    pretty_print_tag 'empty', q
  when nil then
    pretty_print_tag 'open ', q
  else
    raise "Unknown closing #{@closing.inspect}"
  end
end

#pretty_print_tag(type, q) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/test/rails/pp_html_document.rb', line 39

def pretty_print_tag(type, q)
  q.group 1, "(#{type} #{@name.inspect}", ')' do
    unless @attributes.empty? then
      q.breakable
      q.pp @attributes
    end
    unless children_without_newlines.empty? then
      q.breakable
      q.group 1, '[', ']' do
        q.seplist children_without_newlines do |v|
          q.pp v
        end
      end
    end
  end
end