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.
286 287 288 289 |
# File 'lib/cute/taktuk.rb', line 286 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.
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/cute/taktuk.rb', line 291 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.
314 315 316 317 318 319 320 321 322 |
# File 'lib/cute/taktuk.rb', line 314 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.
307 308 309 310 311 312 |
# File 'lib/cute/taktuk.rb', line 307 def valid?(value) TOKENS.each do |token| return true if token =~ /^#{Regexp.escape(value)}.*$/ end return false end |