Class: Markedly::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/markedly/document.rb

Constant Summary collapse

DEFAULT_PORT =
8080

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options = {}) ⇒ Document

Returns a new instance of Document.



18
19
20
21
22
23
24
25
26
# File 'lib/markedly/document.rb', line 18

def initialize(source, options = {})
  @source = File.expand_path(source)
  @path = File.basename(source)
  @port = options[:port] || DEFAULT_PORT
  @markdown = Markdown.new(options[:parse], options[:render])
  initialize_template
  initialize_assets(options)
  initialize_destination
end

Instance Attribute Details

#cssObject (readonly)

Returns the value of attribute css.



15
16
17
# File 'lib/markedly/document.rb', line 15

def css
  @css
end

#destinationObject (readonly)

Returns the value of attribute destination.



12
13
14
# File 'lib/markedly/document.rb', line 12

def destination
  @destination
end

#pathObject (readonly)

Returns the value of attribute path.



13
14
15
# File 'lib/markedly/document.rb', line 13

def path
  @path
end

#portObject (readonly)

Returns the value of attribute port.



16
17
18
# File 'lib/markedly/document.rb', line 16

def port
  @port
end

#sourceObject (readonly)

Returns the value of attribute source.



11
12
13
# File 'lib/markedly/document.rb', line 11

def source
  @source
end

#uriObject (readonly)

Returns the value of attribute uri.



14
15
16
# File 'lib/markedly/document.rb', line 14

def uri
  @uri
end

Instance Method Details

#convertObject



28
29
30
31
32
33
# File 'lib/markedly/document.rb', line 28

def convert
  @dest_file.rewind
  @dest_file.write render(body_html, @css, @port)
  @dest_file.truncate(@dest_file.pos)
  @dest_file.flush
end