Module: DocumentFile

Extended by:
ActiveSupport::Concern
Defined in:
lib/document_file.rb,
lib/document_file/version.rb,
lib/document_file/collection.rb

Defined Under Namespace

Modules: ClassMethods Classes: Collection

Constant Summary collapse

VERSION =
'0.0.8'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



15
16
17
# File 'lib/document_file.rb', line 15

def content
  @content
end

#dataObject (readonly)

Returns the value of attribute data.



15
16
17
# File 'lib/document_file.rb', line 15

def data
  @data
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



15
16
17
# File 'lib/document_file.rb', line 15

def file_path
  @file_path
end

Instance Method Details

#file_extensionObject



34
35
36
# File 'lib/document_file.rb', line 34

def file_extension
  File.extname file_name_with_extension
end

#file_nameObject



26
27
28
# File 'lib/document_file.rb', line 26

def file_name
  File.basename file_name_with_extension, file_extension
end

#file_name_with_extensionObject



30
31
32
# File 'lib/document_file.rb', line 30

def file_name_with_extension
  self.file_path.split('/').last
end

#initialize(new_file_path) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/document_file.rb', line 17

def initialize(new_file_path)
  @file_path = if File.exist? new_file_path
                 new_file_path
               else
                 [self.documents_dir, new_file_path].join('/')
               end
  read_yaml
end