Class: Wtf::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/wtf/core.rb

Instance Method Summary collapse

Instance Method Details

#cleanObject



18
19
20
21
22
23
24
25
26
# File 'lib/wtf/core.rb', line 18

def clean
  if is_documented?
    File.delete(wtf_file)
    true
  else
    puts not_documented
    nil
  end
end

#contentObject Also known as: read_documentation



36
37
38
39
40
41
42
43
# File 'lib/wtf/core.rb', line 36

def content
  if is_documented?
    data = File.read(wtf_file)
    data
  else
    puts not_documented
  end
end

#current_pathObject



4
5
6
# File 'lib/wtf/core.rb', line 4

def current_path
  Dir.pwd
end

#has_documentation?Boolean Also known as: is_documented?

Returns:

  • (Boolean)


8
9
10
# File 'lib/wtf/core.rb', line 8

def has_documentation?
  File.exist?(wtf_file)
end

#not_documentedObject



28
29
30
# File 'lib/wtf/core.rb', line 28

def not_documented
  "This folder is not documented yet. Add a documentation by running: \n\n wtf doc -c 'a description of the folder'"
end

#write(data) ⇒ Object



32
33
34
# File 'lib/wtf/core.rb', line 32

def write(data)
  File.open(wtf_file, 'w') {|f| f.write(data) }
end

#wtf_fileObject



14
15
16
# File 'lib/wtf/core.rb', line 14

def wtf_file
  current_path + '/.wtf'
end