aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/tokenstream.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-01 07:45:16 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-01 07:45:16 +0000
commit46580b51477355fece514573c88cb67030f4a502 (patch)
tree779c1a64466643461b3daa4cd9a3548b84f0fd55 /lib/rdoc/tokenstream.rb
parent9b40cdfe8c973a061c5683ad78c283b9ddb8b2e9 (diff)
downloadruby-46580b51477355fece514573c88cb67030f4a502.tar.gz
Import RDoc 2.5
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/tokenstream.rb')
-rw-r--r--lib/rdoc/tokenstream.rb37
1 files changed, 28 insertions, 9 deletions
diff --git a/lib/rdoc/tokenstream.rb b/lib/rdoc/tokenstream.rb
index 0a1eb9130b..b1e86543f7 100644
--- a/lib/rdoc/tokenstream.rb
+++ b/lib/rdoc/tokenstream.rb
@@ -9,25 +9,44 @@ module RDoc; end
module RDoc::TokenStream
- def token_stream
- @token_stream
+ ##
+ # Adds +tokens+ to the collected tokens
+
+ def add_tokens(*tokens)
+ tokens.flatten.each { |token| @token_stream << token }
end
- def start_collecting_tokens
+ alias add_token add_tokens
+
+ ##
+ # Starts collecting tokens
+
+ def collect_tokens
@token_stream = []
end
- def add_token(tk)
- @token_stream << tk
- end
+ alias start_collecting_tokens collect_tokens
- def add_tokens(tks)
- tks.each {|tk| add_token(tk)}
- end
+ ##
+ # Remove the last token from the collected tokens
def pop_token
@token_stream.pop
end
+ ##
+ # Current token stream
+
+ def token_stream
+ @token_stream
+ end
+
+ ##
+ # Returns a string representation of the token stream
+
+ def tokens_to_s
+ token_stream.map { |token| token.text }.join ''
+ end
+
end