Class: TextToNoise::CommandLine
- Inherits:
-
Object
- Object
- TextToNoise::CommandLine
- Includes:
- Logging
- Defined in:
- lib/text_to_noise/command_line.rb
Constant Summary collapse
- DEFAULT_FILE_DELAY =
100
Instance Attribute Summary collapse
-
#mapping ⇒ Object
readonly
Returns the value of attribute mapping.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(mapping_configurations, options = {}) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #player ⇒ Object
- #run ⇒ Object
Methods included from Logging
Constructor Details
#initialize(mapping_configurations, options = {}) ⇒ CommandLine
Returns a new instance of CommandLine.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/text_to_noise/command_line.rb', line 10 def initialize( mapping_configurations, ={} ) @options = { :input => $stdin }.merge configs = Array === mapping_configurations ? mapping_configurations : [mapping_configurations] raise ArgumentError, "No configuration file provided." if configs.empty? @mapping = Router.parse File.read( configs.first ) TextToNoise.player = self.player TextToNoise.throttle_delay = @options[:throttle] if @options[:throttle] TextToNoise.throttle_delay = @options[:throttle] || DEFAULT_FILE_DELAY if @options[:input] != $stdin TextToNoise.logger.level = Logger::DEBUG if @options[:debug] rescue Errno::ENOENT => e raise ArgumentError, "Could not locate configuration file: '#{configs.first}' (#{e})" end |
Instance Attribute Details
#mapping ⇒ Object (readonly)
Returns the value of attribute mapping.
6 7 8 |
# File 'lib/text_to_noise/command_line.rb', line 6 def mapping @mapping end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/text_to_noise/command_line.rb', line 6 def @options end |
Instance Method Details
#player ⇒ Object
37 38 39 |
# File 'lib/text_to_noise/command_line.rb', line 37 def player @options[:mute] ? MutePlayer.new : Player.new end |
#run ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/text_to_noise/command_line.rb', line 29 def run LogReader.new( [:input], mapping ).call info "Input processing complete. Waiting for playback to finish..." while TextToNoise.player. sleep 1 end end |