Class: Standoff::Tag

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Tag

Returns a new instance of Tag.



120
121
122
123
124
125
126
# File 'lib/standoff.rb', line 120

def initialize(options = {})
  @name = options[:name] # string
  @attributes = options[:attributes] # hash
  @content = options[:content] # string
  @start = options[:start] # numeric
  @end = options[:end] 
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



119
120
121
# File 'lib/standoff.rb', line 119

def attributes
  @attributes
end

#contentObject

Returns the value of attribute content.



119
120
121
# File 'lib/standoff.rb', line 119

def content
  @content
end

#endObject

Returns the value of attribute end.



119
120
121
# File 'lib/standoff.rb', line 119

def end
  @end
end

#nameObject

Returns the value of attribute name.



119
120
121
# File 'lib/standoff.rb', line 119

def name
  @name
end

#startObject

Returns the value of attribute start.



119
120
121
# File 'lib/standoff.rb', line 119

def start
  @start
end

Instance Method Details

#<=>(other) ⇒ Object



127
128
129
# File 'lib/standoff.rb', line 127

def <=> (other)
    return @end <=> other.end
end

#overlap(other_tag) ⇒ Object



130
131
132
# File 'lib/standoff.rb', line 130

def overlap (other_tag)
  ! ((@start .. @end).to_a & (other_tag.start .. other_tag.end).to_a).empty?
end