Class: Jekyll::Compose::FileCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-compose/file_creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_info, force = false, root = nil) ⇒ FileCreator

Returns a new instance of FileCreator.



7
8
9
10
11
# File 'lib/jekyll-compose/file_creator.rb', line 7

def initialize(file_info, force = false, root = nil)
  @file = file_info
  @force = force
  @root = root
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



6
7
8
# File 'lib/jekyll-compose/file_creator.rb', line 6

def file
  @file
end

#forceObject (readonly)

Returns the value of attribute force.



6
7
8
# File 'lib/jekyll-compose/file_creator.rb', line 6

def force
  @force
end

#rootObject (readonly)

Returns the value of attribute root.



6
7
8
# File 'lib/jekyll-compose/file_creator.rb', line 6

def root
  @root
end

Instance Method Details

#create!Object



13
14
15
16
17
18
# File 'lib/jekyll-compose/file_creator.rb', line 13

def create!
  return unless create?

  ensure_directory_exists
  write_file
end

#file_pathObject



20
21
22
23
24
# File 'lib/jekyll-compose/file_creator.rb', line 20

def file_path
  return file.path if root.nil? || root.empty?

  File.join(root, file.path)
end