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
14 15 16 |
# File 'lib/cheatly/adapter/file.rb', line 14 def all Dir["sheets/*.yml"].map { |f| f.scan(/sheets\/(.*).yml/)[0][0] } end |
#create(name, body) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/cheatly/adapter/file.rb', line 18 def create(name, body) body = {name => body}.to_yaml f = ::File.new("sheets/#{name}.yml", "w") f.write(body) f.close end |
#find(name) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/cheatly/adapter/file.rb', line 7 def find(name) path = "sheets/#{name}.yml" sheet_yaml = ::File.read(path) yml = YAML.load(sheet_yaml).first [yml.first, yml.last] end |
#update(name, body) ⇒ Object
25 26 27 28 |
# File 'lib/cheatly/adapter/file.rb', line 25 def update(name, body) ::File.delete("sheets/#{name}.yml") create(name, body) end |