Class: Ned::Prepend
Instance Method Summary collapse
Methods inherited from Command
config, description, #execute, #execute_all, help, #initialize, #load_lines, long_name, option_parser, #options, #peek, require_all, #require_all, #require_all?, require_all?, short_name
Constructor Details
This class inherits a constructor from Ned::Command
Instance Method Details
#execute_internal(line) ⇒ Object
22 23 24 25 |
# File 'lib/ned/commands/prepend.rb', line 22 def execute_internal(line) line.insert(0, @prepend) @require_split ? line.split(/(?<=\n)/) : line end |
#parse(args) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ned/commands/prepend.rb', line 14 def parse(args) super raise OptionParser::ParseError.new("missing string argument") if args.size == 0 @prepend = args.shift @require_split = !!@prepend.index("\n") end |