Module: L43MyRuby::MapLines

Extended by:
MapLines
Includes:
ExAequo::Color::Text
Included in:
MapLines
Defined in:
lib/l43_my_ruby/map_lines.rb,
lib/l43_my_ruby/map_lines/pattern_mapper.rb

Defined Under Namespace

Modules: PatternMapper

Instance Method Summary collapse

Instance Method Details

#helpObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/l43_my_ruby/map_lines.rb', line 13

def help
  ExAequo::Color::Text.put_col(
    :green, "usage:\n",
    :blue, "  #{$0}", :cyan, '[options] pattern', reset(2),
    'Reads lines from standard input and transforms according to', :cyan, ' pattern ', :reset, 'before displaying them to standard output',
    "\n\n", :yellow, "  pattern:", reset(2),

    'The following characters are changed in the pattern for each input line, everything in the pattern is put out verbatim',
    "\n",
    cyan('%  ', 2), ' The whole input line', :eol,
    cyan('%c ',2), ' The line number (as e.g. $NR in awk)', :eol, 
    cyan('%f ',2), ' The line number formatted with the string following the "%f"', :eol, 
    cyan('%\d',2), ' The nth field (as e.g. $NF in awk), but ', :bold, '%0 does not work', :reset, :eol,
    '   ',        '    e.g. %f3 -> 001, 002, ...', :eol,
    cyan('%x ',2), ' The current timestamp (in seconds) in hex', :eol,
    :eol, cyan('%% ',2), ' A literal "%"',
    ''
  )
end

#run(lines, args) ⇒ Object



9
10
11
# File 'lib/l43_my_ruby/map_lines.rb', line 9

def run(lines, args)
  PatternMapper.run(lines, args.first, OpenStruct.new)
end