summaryrefslogtreecommitdiff
path: root/lib/rdoc/markup/attr_span.rb
blob: b5c1b3b7b7cd465dceaafaf8b08f68ea1e711918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
##
# An array of attributes which parallels the characters in a string.

class RDoc::Markup::AttrSpan

  ##
  # Creates a new AttrSpan for +length+ characters

  def initialize(length)
    @attrs = Array.new(length, 0)
  end

  ##
  # Toggles +bits+ from +start+ to +length+
  def set_attrs(start, length, bits)
    for i in start ... (start+length)
      @attrs[i] |= bits
    end
  end

  ##
  # Accesses flags for character +n+

  def [](n)
    @attrs[n]
  end

end