Class: TDiary::Style::RdDiary
- Inherits:
-
Object
- Object
- TDiary::Style::RdDiary
- Includes:
- BaseDiary, CategorizableDiary
- Defined in:
- lib/tdiary/style/rd.rb
Instance Method Summary collapse
- #add_section(subtitle, body) ⇒ Object
- #append(body, author = nil) ⇒ Object
-
#initialize(date, title, body, modified = Time::now) ⇒ RdDiary
constructor
A new instance of RdDiary.
- #style ⇒ Object
- #to_html(opt = {}, mode = :HTML) ⇒ Object
Constructor Details
#initialize(date, title, body, modified = Time::now) ⇒ RdDiary
Returns a new instance of RdDiary.
310 311 312 313 314 |
# File 'lib/tdiary/style/rd.rb', line 310 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
339 340 341 342 343 344 345 |
# File 'lib/tdiary/style/rd.rb', line 339 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
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/tdiary/style/rd.rb', line 320 def append( body, = nil ) section = nil body.lines.each do |l| case l when /^=(begin|end)\b/ # do nothing when /^=[^=]/ @sections << RDSection::new( section, ) if section section = l else section = '' unless section section << l end end @sections << RDSection::new( section, ) if section @last_modified = Time::now self end |
#style ⇒ Object
316 317 318 |
# File 'lib/tdiary/style/rd.rb', line 316 def style 'RD' end |
#to_html(opt = {}, mode = :HTML) ⇒ Object
347 348 349 350 351 352 353 354 355 |
# File 'lib/tdiary/style/rd.rb', line 347 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 |