Class: Strigil::Comments

Inherits:
Object
  • Object
show all
Defined in:
lib/strigil/comments.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeComments

Returns a new instance of Comments.



6
7
8
# File 'lib/strigil/comments.rb', line 6

def initialize
  @log = []
end

Instance Attribute Details

#logObject

Returns the value of attribute log.



4
5
6
# File 'lib/strigil/comments.rb', line 4

def log
  @log
end

Instance Method Details

#add_comment(comment) ⇒ Object



14
15
16
# File 'lib/strigil/comments.rb', line 14

def add_comment(comment)
  @log.push(comment)
end

#add_comments(comments) ⇒ Object



10
11
12
# File 'lib/strigil/comments.rb', line 10

def add_comments(comments)
  @log += comments
end

#clearObject



27
28
29
# File 'lib/strigil/comments.rb', line 27

def clear
  @log = []
end

#saveObject



18
19
20
21
22
23
24
25
# File 'lib/strigil/comments.rb', line 18

def save
  unless File.exist?('./data/')
    FileUtils.mkdir('./data/')
  end
  File.open("./data/comments.json", 'w') do |f|
    f.write(log_to_json)
  end
end