Class: ContentfulMiddleman::LocalData::File

Inherits:
Object
  • Object
show all
Defined in:
lib/contentful_middleman/local_data/file.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, path) ⇒ File

Returns a new instance of File.



14
15
16
17
# File 'lib/contentful_middleman/local_data/file.rb', line 14

def initialize(data, path)
  @data = data
  @path = path
end

Class Method Details

.thorObject



9
10
11
# File 'lib/contentful_middleman/local_data/file.rb', line 9

def thor
  @thor
end

.thor=(thor) ⇒ Object



5
6
7
# File 'lib/contentful_middleman/local_data/file.rb', line 5

def thor=(thor)
  @thor = thor
end

Instance Method Details

#local_data_file_pathObject



23
24
25
26
# File 'lib/contentful_middleman/local_data/file.rb', line 23

def local_data_file_path
  base_path = LocalData::Store.base_path
  ::File.join(base_path, @path + ".yaml")
end

#writeObject



19
20
21
# File 'lib/contentful_middleman/local_data/file.rb', line 19

def write
  self.class.thor.create_file(local_data_file_path, nil, {}) { @data }
end