Class: TDiary::Style::RdDiary

Inherits:
Object
  • Object
show all
Defined in:
lib/tdiary/style/rd.rb

Instance Method Summary collapse

Constructor Details

#initialize(date, title, body, modified = Time::now) ⇒ RdDiary

Returns a new instance of RdDiary.



291
292
293
294
295
# File 'lib/tdiary/style/rd.rb', line 291

def initialize( date, title, body, modified = Time::now )
  init_diary
  replace( date, title, body )
  @last_modified = modified
end

Instance Method Details

#add_section(subtitle, body) ⇒ Object



320
321
322
323
324
325
326
# File 'lib/tdiary/style/rd.rb', line 320

def add_section(subtitle, body)
  sec = RDSection::new("\n")
  sec.subtitle = subtitle
  sec.body     = body
  @sections << sec
  @sections.size
end

#append(body, author = nil) ⇒ Object



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/tdiary/style/rd.rb', line 301

def append( body, author = nil )
  section = nil
  body.lines.each do |l|
    case l
    when /^=(begin|end)\b/
      # do nothing
    when /^=[^=]/
      @sections << RDSection::new( section, author ) if section
      section = l
    else
      section = '' unless section
      section << l
    end
  end
  @sections << RDSection::new( section, author ) if section
  @last_modified = Time::now
  self
end

#styleObject



297
298
299
# File 'lib/tdiary/style/rd.rb', line 297

def style
  'RD'
end

#to_html(opt = {}, mode = :HTML) ⇒ Object



328
329
330
331
332
333
334
335
336
# File 'lib/tdiary/style/rd.rb', line 328

def to_html( opt = {}, mode = :HTML )
  r = ''
  idx = 1
  each_section do |section|
    r << section.html( date, idx, opt, mode )
    idx += 1
  end
  return r
end