Method: LogicTools#each_input
- Defined in:
- lib/logic_tools/logicinput.rb
#each_input ⇒ Object
Gets an iterator over the input expression
(obtained either through options or a through file).
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/logic_tools/logicinput.rb', line 19 def each_input # No block? Return an enumerator return enum_for(:each_input) unless block_given? # A block? Interrate with it # Process the arguments if ($*.empty?) then # No arguments, shows the help and end. help_short exit(1) end if $*[0] == "-f" or $*[0] == "--file" then # Work from a file, iterate on each line exprs = File.read($*[1]) exprs.gsub!(/\r\n?/, "\n") exprs.each_line do |line| yield(line) end elsif $*[0] == "-h" or $*[0] == "--help" then help_short else # Work directly on the arguments as an expression yield($*.join) end end |