Class: RI::AttributeFormatter::AttributeString

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc/ri/ri_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAttributeString

Returns a new instance of AttributeString.



270
271
272
273
# File 'lib/rdoc/ri/ri_formatter.rb', line 270

def initialize
  @txt = []
  @optr = 0
end

Instance Attribute Details

#txtObject (readonly)

Returns the value of attribute txt



268
269
270
# File 'lib/rdoc/ri/ri_formatter.rb', line 268

def txt
  @txt
end

Instance Method Details

#<<(char) ⇒ Object



275
276
277
# File 'lib/rdoc/ri/ri_formatter.rb', line 275

def <<(char)
  @txt << char
end

#empty?Boolean

Returns:

  • (Boolean)


279
280
281
# File 'lib/rdoc/ri/ri_formatter.rb', line 279

def empty?
  @optr >= @txt.length
end

#next_wordObject

accept non space, then all following spaces



284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/rdoc/ri/ri_formatter.rb', line 284

def next_word
  start = @optr
  len = @txt.length

  while @optr < len && @txt[@optr].char != " "
    @optr += 1
  end

  while @optr < len && @txt[@optr].char == " "
    @optr += 1
  end

  @txt[start...@optr]
end