Class: Strigil::Comments
- Inherits:
-
Object
- Object
- Strigil::Comments
- Defined in:
- lib/strigil/comments.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
Instance Method Summary collapse
- #add_comment(comment) ⇒ Object
- #add_comments(comments) ⇒ Object
- #clear ⇒ Object
-
#initialize ⇒ Comments
constructor
A new instance of Comments.
- #save ⇒ Object
Constructor Details
#initialize ⇒ Comments
Returns a new instance of Comments.
6 7 8 |
# File 'lib/strigil/comments.rb', line 6 def initialize @log = [] end |
Instance Attribute Details
#log ⇒ Object
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 |
#clear ⇒ Object
27 28 29 |
# File 'lib/strigil/comments.rb', line 27 def clear @log = [] end |
#save ⇒ Object
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 |