Class: Paragraph
Overview
Paragraph class
Management a paragraph.
Instance Attribute Summary collapse
-
#body ⇒ Object
(also: #body_to_html)
readonly
Returns the value of attribute body.
-
#subtitle ⇒ Object
(also: #subtitle_to_html)
readonly
Returns the value of attribute subtitle.
Instance Method Summary collapse
- #author ⇒ Object
-
#initialize(fragment, author = nil) ⇒ Paragraph
constructor
A new instance of Paragraph.
- #to_s ⇒ Object
- #to_src ⇒ Object
Constructor Details
#initialize(fragment, author = nil) ⇒ Paragraph
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/tdiary/io/pstore.rb', line 99 def initialize( fragment, = nil ) = lines = fragment.split( /\n+/ ) if lines.size > 1 then if /^<</ =~ lines[0] @subtitle = lines.shift.chomp.sub( /^</, '' ) elsif /^[ <]/u !~ lines[0] @subtitle = lines.shift.chomp end end @body = lines.join( "\n" ) end |
Instance Attribute Details
#body ⇒ Object (readonly) Also known as: body_to_html
Returns the value of attribute body.
95 96 97 |
# File 'lib/tdiary/io/pstore.rb', line 95 def body @body end |
#subtitle ⇒ Object (readonly) Also known as: subtitle_to_html
Returns the value of attribute subtitle.
95 96 97 |
# File 'lib/tdiary/io/pstore.rb', line 95 def subtitle @subtitle end |
Instance Method Details
#author ⇒ Object
126 127 128 129 |
# File 'lib/tdiary/io/pstore.rb', line 126 def = @auther unless end |
#to_s ⇒ Object
122 123 124 |
# File 'lib/tdiary/io/pstore.rb', line 122 def to_s "subtitle=#{@subtitle}, body=#{@body}" end |
#to_src ⇒ Object
112 113 114 115 116 117 118 119 120 |
# File 'lib/tdiary/io/pstore.rb', line 112 def to_src s = '' if @subtitle then s += "[#{@author}]" if s += '<' if /^</ =~ @subtitle s += @subtitle + "\n" end "#{s}#{@body}\n\n" end |