Parent

Methods

Class/Module Index [+]

Quicksearch

MCollective::Matcher::Scanner

Attributes

arguments[RW]
token_index[RW]

Public Instance Methods

get_token() click to toggle source

Scans the input string and identifies single language tokens

# File lib/mcollective/matcher/scanner.rb, line 12
def get_token
  if @token_index >= @arguments.size
    return nil
  end

  begin
    case @arguments.split("")[@token_index]
    when "("
      return "(", "("

    when ")"
      return ")", ")"

    when "n"
      if (@arguments.split("")[@token_index + 1] == "o") && (@arguments.split("")[@token_index + 2] == "t") && ((@arguments.split("")[@token_index + 3] == " ") || (@arguments.split("")[@token_index + 3] == "("))
        @token_index += 2
        return "not", "not"
      else
        gen_statement
      end

    when "!"
      return "not", "not"

    when "a"
      if (@arguments.split("")[@token_index + 1] == "n") && (@arguments.split("")[@token_index + 2] == "d") && ((@arguments.split("")[@token_index + 3] == " ") || (@arguments.split("")[@token_index + 3] == "("))
        @token_index += 2
        return "and", "and"
      else
        gen_statement
      end

    when "o"
      if (@arguments.split("")[@token_index + 1] == "r") && ((@arguments.split("")[@token_index + 2] == " ") || (@arguments.split("")[@token_index + 2] == "("))
        @token_index += 1
        return "or", "or"
      else
        gen_statement
      end

    when " "
      return " ", " "

    else
      gen_statement
    end
  end
rescue NoMethodError => e
  pp e
  raise "Cannot end statement with 'and', 'or', 'not'"
end

Public Class Methods

new(arguments) click to toggle source
# File lib/mcollective/matcher/scanner.rb, line 6
def initialize(arguments)
  @token_index = 0
  @arguments = arguments
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.