Class: Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_diff/htmlize.rb

Overview

A Tag wrapping an element in an HTML file. It contains information about the node wrapped inside it such as the start and end offset. The tag attr contains the actual HTML, and includes information used to style the nodes based on whether its an insertion, deletion or modification. Matching modifications are wrapped in anchor tags so they can be linked to their matches.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Tag) initialize(tag, idx, start = -1))

Construct a new tag.

Parameters:

  • tag (String)

    An HTML tag.

  • idx (Fixnum)

    for open tag: start offset. closing tag: end offset

  • start (Fixnum) (defaults to: -1))

    for open tag: -1. for closing tag: start offset.



27
28
29
30
31
# File 'lib/smart_diff/htmlize.rb', line 27

def initialize(tag, idx, start=-1)
  @tag = tag
  @idx = idx
  @start = start
end

Instance Attribute Details

- (Object) idx

Returns the value of attribute idx



16
17
18
# File 'lib/smart_diff/htmlize.rb', line 16

def idx
  @idx
end

- (Object) start

Returns the value of attribute start



16
17
18
# File 'lib/smart_diff/htmlize.rb', line 16

def start
  @start
end

- (Object) tag

Returns the value of attribute tag



16
17
18
# File 'lib/smart_diff/htmlize.rb', line 16

def tag
  @tag
end

Instance Method Details

- (String) to_s

String representation of the Tag object.

Returns:

  • (String)

    Tag as string.



38
39
40
# File 'lib/smart_diff/htmlize.rb', line 38

def to_s
  "tag: #{@tag}, idx: #{@idx} start: #{@start}"
end