class WikiMd::Entry

Attributes

body[R]
heading[R]
tags[R]
x[R]

Public Class Methods

new(rx, debug: false) click to toggle source
# File lib/wiki_md.rb, line 22
def initialize(rx, debug: false)
  
  @rx, @debug = rx, debug
  @x = @rx.x
  parse_x()
  
end

Public Instance Methods

body=(s) click to toggle source
# File lib/wiki_md.rb, line 30
def body=(s)
  text_entry = "# %s\n\n%s\n\n%s" % [self.heading, s, self.footer]
  self.x = text_entry
end
id() click to toggle source
# File lib/wiki_md.rb, line 41
def id()
  @rx.id
end
to_s(compact: false) click to toggle source
# File lib/wiki_md.rb, line 50
def to_s(compact: false)
  
  if !compact then
    
    @x.clone + "\n\n"
    
  else
    '# ' + @heading + ' #' + @tags.join(' #') + "\n\n" + @body
  end

end
x=(s) click to toggle source
# File lib/wiki_md.rb, line 45
def x=(s)
  @rx.x = s
  parse_x()
end

Private Instance Methods

parse_x() click to toggle source
# File lib/wiki_md.rb, line 64
def parse_x()
  
  a = @rx.x.lines
  puts 'a: ' + a.inspect if @debug
  
  @heading, @footer, @body = a.shift.chomp[/(?<=# ).*/], a.pop, 
      a.join.strip
  @tags = @footer[1..-1].strip.split
  
end