Class: Document::Document

Inherits:
Object
  • Object
show all
Includes:
Dom::Node
Defined in:
lib/document/document.rb

Constant Summary collapse

FILE_ENDINGS =
/\.(markdown|mdown|md|mkd|mkdn)$/i

Constants included from Dom::Node

Dom::Node::ABSOLUTE, Dom::Node::LEAF, Dom::Node::NODENAME, Dom::Node::NS_SEP, Dom::Node::NS_SEP_STRING, Dom::Node::RELATIVE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Dom::Node

#[], #add_node, #children, #each_child, #find, #has_children?, #namespace, #parent, #parents, #print_tree, #qualified_name, #resolve, #siblings

Constructor Details

#initialize(path, content) ⇒ Document



13
14
15
16
17
18
19
20
21
# File 'lib/document/document.rb', line 13

def initialize(path, content)
  
  path = File.basename(path).gsub(FILE_ENDINGS, '')
  
  # please do not confuse Filepath of Document (like docs/README.md) with path in Dom
  # an .md will be stripped from the name and README.SOMEMORE.md can be used as path information
  @path, @name, @content = ".#{path}", extract_name_from(path), content
  super()
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



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

def content
  @content
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end