Class: Kwartz::TagInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/kwartz/converter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matched, linenum = nil) ⇒ TagInfo

Returns a new instance of TagInfo.



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/kwartz/converter.rb', line 47

def initialize(matched, linenum=nil)
  @prev_text   = matched[1]
  @tag_text    = matched[2]
  @head_space  = matched[3]
  @is_etag     = matched[4] == '/'
  @tagname     = matched[5]
  @attr_str    = matched[6]
  @extra_space = matched[7]
  @is_empty    = matched[8] == '/'
  @tail_space  = matched[9]
  @linenum = linenum
end

Instance Attribute Details

#attr_strObject

Returns the value of attribute attr_str.



61
62
63
# File 'lib/kwartz/converter.rb', line 61

def attr_str
  @attr_str
end

#extra_spaceObject

Returns the value of attribute extra_space.



61
62
63
# File 'lib/kwartz/converter.rb', line 61

def extra_space
  @extra_space
end

#head_spaceObject

Returns the value of attribute head_space.



61
62
63
# File 'lib/kwartz/converter.rb', line 61

def head_space
  @head_space
end

#is_emptyObject Also known as: is_empty?

Returns the value of attribute is_empty.



61
62
63
# File 'lib/kwartz/converter.rb', line 61

def is_empty
  @is_empty
end

#is_etagObject Also known as: is_etag?

Returns the value of attribute is_etag.



61
62
63
# File 'lib/kwartz/converter.rb', line 61

def is_etag
  @is_etag
end

#linenumObject

Returns the value of attribute linenum.



62
63
64
# File 'lib/kwartz/converter.rb', line 62

def linenum
  @linenum
end

#prev_textObject

Returns the value of attribute prev_text.



61
62
63
# File 'lib/kwartz/converter.rb', line 61

def prev_text
  @prev_text
end

#tag_textObject

Returns the value of attribute tag_text.



61
62
63
# File 'lib/kwartz/converter.rb', line 61

def tag_text
  @tag_text
end

#tagnameObject

Returns the value of attribute tagname.



61
62
63
# File 'lib/kwartz/converter.rb', line 61

def tagname
  @tagname
end

#tail_spaceObject

Returns the value of attribute tail_space.



61
62
63
# File 'lib/kwartz/converter.rb', line 61

def tail_space
  @tail_space
end

Instance Method Details

#_inspectObject



92
93
94
# File 'lib/kwartz/converter.rb', line 92

def _inspect
  return [ @prev_text, @head_space, @is_etag, @tagname, @attr_str, @extra_space, @is_empty, @tail_space ]
end

#clear_as_dummy_tagObject

delete <span> tag



86
87
88
89
# File 'lib/kwartz/converter.rb', line 86

def clear_as_dummy_tag    # delete <span> tag
  @tagname = nil
  @head_space = @tail_space = nil if @head_space && @tail_space
end

#rebuild_tag_text(attr_info = nil) ⇒ Object



74
75
76
77
78
79
80
81
82
83
# File 'lib/kwartz/converter.rb', line 74

def rebuild_tag_text(attr_info=nil)
  if attr_info
    sb = ''
    attr_info.each do |space, aname, avalue|
      sb << "#{space}#{aname}=\"#{avalue}\""
    end
    @attr_str = sb
  end
  @tag_text = "#{@head_space}<#{@is_etag ? '/' : ''}#{@tagname}#{@attr_str}#{@extra_space}#{@is_empty ? '/' : ''}>#{@tail_space}"
end