Class: Cute::TakTuk::Commands Private
- Inherits:
-
Array
- Object
- Array
- Cute::TakTuk::Commands
- Defined in:
- lib/cute/taktuk.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Validates the commands accepted by taktuk
Constant Summary collapse
- TOKENS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[ 'broadcast', 'downcast', 'exec', 'get', 'put', 'input', 'data', 'file', 'pipe', 'close', 'line', 'target', 'kill', 'message', 'network', 'state', 'cancel', 'renumber', 'update', 'option', 'synchronize', 'taktuk_perl', 'quit', 'wait', 'reduce' ]
Instance Method Summary collapse
- #<<(val) ⇒ Object private
- #check(val) ⇒ Object private
- #to_cmd ⇒ Object private
- #valid?(value) ⇒ Boolean private
Instance Method Details
#<<(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
344 345 346 347 |
# File 'lib/cute/taktuk.rb', line 344 def <<(val) raise ArgumentError.new("'Invalid TakTuk command '#{val}'") unless check(val) super(val) end |
#check(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'lib/cute/taktuk.rb', line 349 def check(val) if val =~ /^-?\[.*-?\]$|^;$/ true elsif val.nil? or val.empty? false else tmp = val.split(' ',2) return false unless valid?(tmp[0]) if !tmp[1].nil? and !tmp[1].empty? check(tmp[1]) else true end end end |
#to_cmd ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
372 373 374 375 376 377 378 379 380 |
# File 'lib/cute/taktuk.rb', line 372 def to_cmd self.inject([]) do |ret,val| if val =~ /^\[(.*)\]$/ ret += ['[',Regexp.last_match(1).strip,']'] else ret += val.split(' ') end end end |
#valid?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
365 366 367 368 369 370 |
# File 'lib/cute/taktuk.rb', line 365 def valid?(value) TOKENS.each do |token| return true if token =~ /^#{Regexp.escape(value)}.*$/ end return false end |