How do I avoid multiple chain calls?
One way would be to wrap it in an object with each method returning self so that methods can be chained.

class DataObject
  def initialize(data)
    @data = data
  end

  def clean
     @data = @data.data.map(&amp;::strip)
     self
  end

  def write(filename)
    File.open(filename, "w") do |f|
      f.write(@data.to_yaml)
    end
    self
  end

end

def read(filename)
  data = YAML.load_file(filename)
  DataObject.new(data)
end


Another way would be to use mixins.

module DataMethods

  def clean
    # need to use the destructive methods to modify self
    map!(&amp;::strip)
    # or each(&amp;:strip!)
    self
  end

  def write(filename)
    File.write(filename, to_yaml)
    self
  end

end

def read(filename)
  YAML.load_file(filename).extend(DataMethods)
end