Sha256: 9da9c3bb3345b34bd83ac62b3f423cd9dd76bebf25587272df1f4be58f70faf3

Contents?: true

Size: 544 Bytes

Versions: 3

Compression:

Stored size: 544 Bytes

Contents

#encoding: utf-8
module PointRb
  class PointRbFile

    attr_accessor :path, :base_dir, :content

    def initialize(path, content)
      @path = path
      @base_dir = ''
      @content = canonize_string(content)
    end

    def full_path
      if @path =~ /^\//
        @path
      else
        File.join(@base_dir, @path)
      end
    end

    def create
      File.open(full_path, "wb") do |f|
        f.write content
      end
    end

    private

    def canonize_string(str)
      str.strip_heredoc.gsub(/^\n/, '')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pointrb-0.1.2 lib/pointrb/pointrb_file.rb
pointrb-0.1.1 lib/pointrb/pointrb_file.rb
pointrb-0.1.0 lib/pointrb/pointrb_file.rb