Class: Cheatly::FileAdapter
- Inherits:
-
Object
- Object
- Cheatly::FileAdapter
- Defined in:
- lib/cheatly/sheet.rb
Instance Method Summary collapse
Instance Method Details
#all ⇒ Object
66 67 68 |
# File 'lib/cheatly/sheet.rb', line 66 def all Dir["sheets/*.yml"].map { |f| f.scan(/sheets\/(.*).yml/)[0][0] } end |
#create(name, body) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/cheatly/sheet.rb', line 70 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
59 60 61 62 63 64 |
# File 'lib/cheatly/sheet.rb', line 59 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
77 78 79 80 |
# File 'lib/cheatly/sheet.rb', line 77 def update(name, body) File.delete "sheets/#{name}.yml" create(name, body) end |