Class: Crusoe::EntryFile

Inherits:
Object
  • Object
show all
Defined in:
lib/crusoe/entry_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry_file_name) ⇒ EntryFile

Returns a new instance of EntryFile.



14
15
16
17
# File 'lib/crusoe/entry_file.rb', line 14

def initialize(entry_file_name)
  @entry_file_name = entry_file_name.to_s
  @content = content
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



4
5
6
# File 'lib/crusoe/entry_file.rb', line 4

def content
  @content
end

#entry_file_nameObject (readonly)

Returns the value of attribute entry_file_name.



3
4
5
# File 'lib/crusoe/entry_file.rb', line 3

def entry_file_name
  @entry_file_name
end

Class Method Details

.create_unless_exist(entry_file_name, content = "") ⇒ Object



6
7
8
9
10
11
12
# File 'lib/crusoe/entry_file.rb', line 6

def self.create_unless_exist(entry_file_name, content = "")
  entry_file = new(entry_file_name)

  return if entry_file.exist?

  entry_file.write(content)
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/crusoe/entry_file.rb', line 19

def exist?
  File.exist?(entry_file_name)
end

#write(content) ⇒ Object



23
24
25
26
27
# File 'lib/crusoe/entry_file.rb', line 23

def write(content)
  dir_path = File.dirname(entry_file_name.to_s)
  FileUtils.mkdir_p(dir_path)
  File.write(entry_file_name.to_s, content)
end