Class: Como::RuleDisplay
- Inherits:
-
ComoCommon
- Object
- ComoCommon
- Como::RuleDisplay
- Defined in:
- lib/como.rb
Overview
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>
Constant Summary
Constants inherited from ComoCommon
Class Method Summary collapse
-
.print(prefixStr = " ", &rule) ⇒ Object
Eval rules to get an nested array and then display it.
Instance Method Summary collapse
-
#addPrefix(str) ⇒ Object
Increase prefix string.
-
#all(*args) ⇒ Object
All are given.
-
#any(*args) ⇒ Object
At least one is given.
- #evalAndDisplay(&rule) ⇒ Object
-
#follow(*args) ⇒ Object
Incremental options in order i.e.
-
#incr(*args) ⇒ Object
Incremental options in order i.e.
-
#initialize(prefixStr) ⇒ RuleDisplay
constructor
A new instance of RuleDisplay.
-
#inv(*args) ⇒ Object
Logical inversion.
-
#meh(*args) ⇒ Object
Dont care.
-
#none ⇒ Object
Special condition where no arguments are given.
-
#one(*args) ⇒ Object
One of list given.
-
#p(str) ⇒ Object
Print prefix + str.
-
#printRule(arr) ⇒ Object
Recursively go through the nested array of rule items and print out rules.
-
#rmPrefix(item) ⇒ Object
Remove from prefix (either str or length ).
Methods inherited from ComoCommon
getIo, runHook, setHook, setIo
Constructor Details
#initialize(prefixStr) ⇒ RuleDisplay
2099 2100 2101 2102 |
# File 'lib/como.rb', line 2099 def initialize( prefixStr ) # Prefix string for lines. Rules add/rm from it. @prefixStr = prefixStr end |
Class Method Details
.print(prefixStr = " ", &rule) ⇒ Object
Eval rules to get an nested array and then display it.
2094 2095 2096 2097 |
# File 'lib/como.rb', line 2094 def RuleDisplay.print( prefixStr = " ", &rule ) rd = RuleDisplay.new( prefixStr ) rd.evalAndDisplay( &rule ) end |
Instance Method Details
#addPrefix(str) ⇒ Object
Increase prefix string.
2109 2110 2111 |
# File 'lib/como.rb', line 2109 def addPrefix( str ) @prefixStr += str end |
#all(*args) ⇒ Object
All are given.
2173 2174 2175 |
# File 'lib/como.rb', line 2173 def all( *args ) [ "All of", *args ] end |
#any(*args) ⇒ Object
At least one is given.
2168 2169 2170 |
# File 'lib/como.rb', line 2168 def any( *args ) [ "One or more of", *args ] end |
#evalAndDisplay(&rule) ⇒ Object
2104 2105 2106 |
# File 'lib/como.rb', line 2104 def evalAndDisplay( &rule ) printRule( instance_eval( &rule ) ) end |
#follow(*args) ⇒ Object
Incremental options in order i.e. have to have all later if had first.
2158 2159 2160 |
# File 'lib/como.rb', line 2158 def follow( *args ) [ "If first then rest", *args ] end |
#incr(*args) ⇒ Object
Incremental options in order i.e. have to have previous to have later.
2152 2153 2154 |
# File 'lib/como.rb', line 2152 def incr( *args ) [ "Adding in order", *args ] end |
#inv(*args) ⇒ Object
Logical inversion.
2178 2179 2180 |
# File 'lib/como.rb', line 2178 def inv( *args ) [ "Not", *args ] end |
#meh(*args) ⇒ Object
Dont care.
2183 2184 2185 |
# File 'lib/como.rb', line 2183 def meh( *args ) [ "Ignoring", *args ] end |
#none ⇒ Object
Special condition where no arguments are given.
2146 2147 2148 |
# File 'lib/como.rb', line 2146 def none [ "NONE" ] end |
#one(*args) ⇒ Object
One of list given.
2163 2164 2165 |
# File 'lib/como.rb', line 2163 def one( *args ) [ "One of", *args ] end |
#p(str) ⇒ Object
Print prefix + str.
2124 2125 2126 |
# File 'lib/como.rb', line 2124 def p( str ) @@io.puts( @prefixStr + str ) end |
#printRule(arr) ⇒ Object
Recursively go through the nested array of rule items and print out rules.
2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 |
# File 'lib/como.rb', line 2130 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) ⇒ Object
Remove from prefix (either str or length ).
2114 2115 2116 2117 2118 2119 2120 2121 |
# File 'lib/como.rb', line 2114 def rmPrefix( item ) if item.class == String cnt = item.length else cnt = item end @prefixStr = @prefixStr[0..-(cnt+1)] end |