mirror of https://github.com/freeCodeCamp/devdocs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
331 B
26 lines
331 B
10 years ago
|
require 'yajl/json_gem'
|
||
|
|
||
|
module Docs
|
||
|
class PageDb
|
||
|
attr_reader :pages
|
||
|
|
||
|
delegate :empty?, :blank?, to: :pages
|
||
|
|
||
|
def initialize
|
||
|
@pages = {}
|
||
|
end
|
||
|
|
||
|
def add(path, content)
|
||
|
@pages[path] = content
|
||
|
end
|
||
|
|
||
|
def as_json
|
||
|
@pages
|
||
|
end
|
||
|
|
||
|
def to_json
|
||
|
JSON.generate(as_json)
|
||
|
end
|
||
|
end
|
||
|
end
|