Class: PointRb::PointRbFile

Inherits:
Object
  • Object
show all
Defined in:
lib/pointrb/pointrb_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, content) ⇒ PointRbFile

Returns a new instance of PointRbFile.



7
8
9
10
11
# File 'lib/pointrb/pointrb_file.rb', line 7

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

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



5
6
7
# File 'lib/pointrb/pointrb_file.rb', line 5

def base_dir
  @base_dir
end

#contentObject

Returns the value of attribute content.



5
6
7
# File 'lib/pointrb/pointrb_file.rb', line 5

def content
  @content
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/pointrb/pointrb_file.rb', line 5

def path
  @path
end

Instance Method Details

#createObject



21
22
23
24
25
# File 'lib/pointrb/pointrb_file.rb', line 21

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

#full_pathObject



13
14
15
16
17
18
19
# File 'lib/pointrb/pointrb_file.rb', line 13

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