class Redoxed::String

Used in models, contains convenience methods

Attributes

cmd[RW]
name[RW]
type[RW]

Public Class Methods

new(str = '') click to toggle source
Calls superclass method
# File lib/redoxed/string.rb, line 27
def initialize(str = '')
  super
  return unless str.class == Redoxed::String

  @cmd  = str.cmd
  @name = str.name
  @type = str.type
end

Public Instance Methods

cut_both(head = 1, tail = 1) click to toggle source

@return [Redoxed::String] copy of self with first and last lines removed

# File lib/redoxed/string.rb, line 17
def cut_both(head = 1, tail = 1)
  Redoxed::String.new each_line.to_a[head..-1 - tail].join
end
cut_head(lines = 1) click to toggle source

@return [Redoxed::String] copy of self with first line removed

# File lib/redoxed/string.rb, line 12
def cut_head(lines = 1)
  Redoxed::String.new each_line.to_a[lines..-1].join
end
cut_tail(lines = 1) click to toggle source

@return [Redoxed::String] copy of self with last line removed

# File lib/redoxed/string.rb, line 7
def cut_tail(lines = 1)
  Redoxed::String.new each_line.to_a[0..-1 - lines].join
end
set_cmd(command) click to toggle source

sets @cmd and @name unless @name is already set

# File lib/redoxed/string.rb, line 22
def set_cmd(command)
  @cmd = command
  @name ||= @cmd.to_s.strip.gsub(/\s+/, '_') # what to do when command is proc? #to_s seems ghetto
end