Class: Silhouette::ASCIIConverter
- Defined in:
- lib/silhouette/converter.rb
Overview
NOTE: This uses IO#write instead of IO#puts because IO#write is faster as it does a quick test to see if the argument is already a string and just writes it if it is. IO#puts calls respond_to? on all arguments to see if they are strings, which is a lot slower if you do this 20,000 times.
Direct Known Subclasses
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(file) ⇒ ASCIIConverter
constructor
A new instance of ASCIIConverter.
- #process_call(*args) ⇒ Object
- #process_end(*args) ⇒ Object
- #process_file(*args) ⇒ Object
- #process_line(*args) ⇒ Object
- #process_method(*args) ⇒ Object
- #process_return(*args) ⇒ Object
- #process_start(*args) ⇒ Object
Methods inherited from Processor
Constructor Details
#initialize(file) ⇒ ASCIIConverter
Returns a new instance of ASCIIConverter.
10 11 12 |
# File 'lib/silhouette/converter.rb', line 10 def initialize(file) @io = File.open(file, "w") end |
Instance Method Details
#close ⇒ Object
42 43 44 |
# File 'lib/silhouette/converter.rb', line 42 def close @io.close end |
#process_call(*args) ⇒ Object
30 31 32 |
# File 'lib/silhouette/converter.rb', line 30 def process_call(*args) @io.write "c #{args.join(' ')}\n" end |
#process_end(*args) ⇒ Object
18 19 20 |
# File 'lib/silhouette/converter.rb', line 18 def process_end(*args) @io.write "@ #{args.join(' ')}\n" end |
#process_file(*args) ⇒ Object
26 27 28 |
# File 'lib/silhouette/converter.rb', line 26 def process_file(*args) @io.write "* #{args.join(' ')}\n" end |
#process_line(*args) ⇒ Object
38 39 40 |
# File 'lib/silhouette/converter.rb', line 38 def process_line(*args) @io.write "l #{args.join(' ')}\n" end |
#process_method(*args) ⇒ Object
22 23 24 |
# File 'lib/silhouette/converter.rb', line 22 def process_method(*args) @io.write "& #{args.join(' ')}\n" end |
#process_return(*args) ⇒ Object
34 35 36 |
# File 'lib/silhouette/converter.rb', line 34 def process_return(*args) @io.write "r #{args.join(' ')}\n" end |
#process_start(*args) ⇒ Object
14 15 16 |
# File 'lib/silhouette/converter.rb', line 14 def process_start(*args) @io.write "! #{args.join(' ')}\n" end |