module Refinements
Public Instance Methods
Source
# File lib/refinements.rb, line 21 def cut_both(head = 1, tail = 1) return "" if length.zero? each_line.to_a[head..(-1 - tail)].join end
@return [String] copy of self with first and last lines removed
Source
# File lib/refinements.rb, line 14 def cut_head(lines = 1) return "" if length.zero? each_line.to_a[lines..-1].join end
@return [String] copy of self with first line removed
Source
# File lib/refinements.rb, line 7 def cut_tail(lines = 1) return "" if length.zero? each_line.to_a[0..(-1 - lines)].join end
@return [String] copy of self with last line removed
Source
# File lib/refinements.rb, line 37 def init_from_string(str = '') raise TypeError unless str.instance_of?(String) @cmd = str.instance_variable_get(:@cmd) @name = str.instance_variable_get(:@name) @type = str.instance_variable_get(:@type) end
Initializes the String instance variables from another String instance when the given str is an instance of String with Oxidized
refinements applied
Source
# File lib/refinements.rb, line 28 def process_cmd(command) @cmd = command # rubocop:disable Naming/MemoizedInstanceVariableName @name ||= @cmd.to_s.strip.gsub(/\s+/, '_') # what to do when command is proc? #to_s seems ghetto # rubocop:enable Naming/MemoizedInstanceVariableName end
sets @cmd and @name unless @name is already set