blob: 6fe939fe7d5d1492ce10569434d3605cbee3dedb (
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
30
31
32
33
34
35
36
|
# frozen_string_literal: true
##
# 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, exclusive)
@attrs = Array.new(length, 0)
@exclusive = exclusive
end
##
# Toggles +bits+ from +start+ to +length+
def set_attrs(start, length, bits)
updated = false
for i in start ... (start+length)
if (@exclusive & @attrs[i]) == 0
@attrs[i] |= bits
updated = true
end
end
updated
end
##
# Accesses flags for character +n+
def [](n)
@attrs[n]
end
end
|