Class: Cheatly::Adapter::File
- Inherits:
-
Object
- Object
- Cheatly::Adapter::File
- Defined in:
- lib/cheatly/adapter/file.rb
Instance Method Summary collapse
Instance Method Details
#all ⇒ Object
12 13 14 |
# File 'lib/cheatly/adapter/file.rb', line 12 def all Dir["sheets/*.md"].map { |f| f.scan(/sheets\/(.*).md/)[0][0] } end |
#create(name, body) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/cheatly/adapter/file.rb', line 16 def create(name, body) body = {name => body}.to_yaml f = ::File.new("sheets/#{name}.md", "w") f.write(body) f.close end |
#find(name) ⇒ Object
7 8 9 10 |
# File 'lib/cheatly/adapter/file.rb', line 7 def find(name) path = "sheets/#{name}.md" ::File.read(path) end |
#update(name, body) ⇒ Object
23 24 25 26 |
# File 'lib/cheatly/adapter/file.rb', line 23 def update(name, body) ::File.delete("sheets/#{name}.md") create(name, body) end |