class Como::RuleDisplay

Display utility for RuleCheck. Usage model.

RuleDisplay.new.evalAndDisplay( &rule )

Example expansion of options:

   |--# One of:
   |     |--# Adding in order:
   |     |     |--<gcov>
   |     |     |--<exclude>
   |     |     |--<refreshed>
   |     |--<manifest>
   |     |--<pairs>
   |     |--<files>

Public Class Methods

new( prefixStr ) click to toggle source

Create rule displayer.

# File lib/como.rb, line 2368
def initialize( prefixStr )
    # Prefix string for lines. Rules add/rm from it.
    @prefixStr = prefixStr
end
print( prefixStr = " ", &rule ) click to toggle source

Eval rules to get an nested array and then display it.

Public Instance Methods

addPrefix( str ) click to toggle source

Increase prefix string.

# File lib/como.rb, line 2379
def addPrefix( str )
    @prefixStr += str
end
all( *args ) click to toggle source

All are given.

# File lib/como.rb, line 2443
def all( *args )
    [ "All of", *args ]
end
any( *args ) click to toggle source

At least one is given.

# File lib/como.rb, line 2438
def any( *args )
    [ "One or more of", *args ]
end
evalAndDisplay( &rule ) click to toggle source

Display method.

# File lib/como.rb, line 2374
def evalAndDisplay( &rule )
    printRule( instance_eval( &rule ) )
end
follow( *args ) click to toggle source

Incremental options in order i.e. have to have all later if had first.

# File lib/como.rb, line 2428
def follow( *args )
    [ "If first then rest", *args ]
end
incr( *args ) click to toggle source

Incremental options in order i.e. have to have previous to have later.

# File lib/como.rb, line 2422
def incr( *args )
    [ "Adding in order", *args ]
end
inv( *args ) click to toggle source

Logical inversion.

# File lib/como.rb, line 2448
def inv( *args )
    [ "Not", *args ]
end
meh( *args ) click to toggle source

Dont care.

# File lib/como.rb, line 2453
def meh( *args )
    [ "Ignoring", *args ]
end
none() click to toggle source

Special condition where no arguments are given.

# File lib/como.rb, line 2416
def none
    [ "NONE" ]
end
one( *args ) click to toggle source

One of list given.

# File lib/como.rb, line 2433
def one( *args )
    [ "One of", *args ]
end
p( str ) click to toggle source

Print prefix + str.

# File lib/como.rb, line 2394
def p( str )
    @@io.puts( @prefixStr + str )
end
printRule( arr ) click to toggle source

Recursively go through the nested array of rule items and print out rules.

# File lib/como.rb, line 2400
def printRule( arr )
    p( "|--# #{arr[0]}:" )
    item = "|     "
    addPrefix( item )

    arr[1..-1].each do |i|
        if i.class == Array
            printRule( i )
        else
            p( "|--<#{i}>" )
        end
    end
    rmPrefix( item )
end
rmPrefix( item ) click to toggle source

Remove from prefix (either str or length ).

# File lib/como.rb, line 2384
def rmPrefix( item )
    if item.class == String
        cnt = item.length
    else
        cnt = item
    end
    @prefixStr = @prefixStr[0..-(cnt+1)]
end