class Shift::String

String result from one of the operations. Extends string with some useful helper methods to write to disk, do further transformations etc, allowing chaining of operations.

Public Class Methods

new(str='', name=nil) click to toggle source

Create a new shift string from a standard string. @param [String] str The source string @param [String] name A file path, partial path, or

extension associated with the string.

@return [Shift::String] A Shift string that can be

manipulated further.
Calls superclass method
# File lib/shift/string.rb, line 97
def initialize(str='', name=nil)
  super(str)
  @name = name
end

Public Instance Methods

append_read(path)
Alias for: read_append
data() click to toggle source
# File lib/shift/string.rb, line 102
def data
  self
end
read_append(path) click to toggle source

Read a file and append its contents.

# File lib/shift/string.rb, line 108
def read_append(path)
  data << File.read(path)
  self
end
Also aliased as: append_read
write(name_override=nil) click to toggle source

Write the string to a sepcified path. @ return self

# File lib/shift/string.rb, line 116
def write(name_override=nil)
  path = name_override || name || name_error
  File.open(path, 'w') {|f| f.write(data) }
  self
end