Class: Adocsite::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/adocsite/content_types.rb

Direct Known Subclasses

Article, Page

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adoc) ⇒ Content

Returns a new instance of Content.



4
5
6
7
8
# File 'lib/adocsite/content_types.rb', line 4

def initialize(adoc)
  @name = Content::title_to_name(adoc.doctitle)
  @title = adoc.doctitle
  @content = adoc.content
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/adocsite/content_types.rb', line 3

def name
  @name
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/adocsite/content_types.rb', line 3

def title
  @title
end

Class Method Details

.title_to_name(title) ⇒ Object



10
11
12
13
14
# File 'lib/adocsite/content_types.rb', line 10

def self.title_to_name(title)
  title = title.strip
  title = title.gsub(/[^0-9A-Za-z.\-]/, '_')
  title = title.gsub(/[_]+/, '_')
end

Instance Method Details

#contentObject



21
22
23
# File 'lib/adocsite/content_types.rb', line 21

def content()
  @content = @content.gsub(/sitenav:['"](.*)['"](\[(.*)\])?/) {|sitenav| stringreturn("#$1","#$3")}
end