Class: Markdaver::MarkdownEditorEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/markdaver/markdown_editor_env.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_path: File.expand_path("../../../markdown-editor/"), script_file: nil, file_to_open: nil) ⇒ MarkdownEditorEnv

Returns a new instance of MarkdownEditorEnv.



5
6
7
8
9
10
11
12
13
# File 'lib/markdaver/markdown_editor_env.rb', line 5

def initialize(
  root_path: File.expand_path("../../../markdown-editor/"),
  script_file: nil,
  file_to_open: nil
)
  @root_path = root_path
  @script_file = script_file
  @file_to_open = file_to_open
end

Instance Attribute Details

#root_pathObject (readonly)

Returns the value of attribute root_path.



3
4
5
# File 'lib/markdaver/markdown_editor_env.rb', line 3

def root_path
  @root_path
end

Instance Method Details

#indexObject



15
16
17
18
# File 'lib/markdaver/markdown_editor_env.rb', line 15

def index
  @index ||= File.read(File.join @root_path, "index.html")
    .gsub(/<\/body>/, "\n<script>#{script}</script>\\0")
end