Class: DNote::Format
- Inherits:
-
Object
- Object
- DNote::Format
- Defined in:
- lib/dnote/format.rb
Overview
Notes Formatter
–
TODO: Need good CSS file.
TODO: Need XSL?
++
Defined Under Namespace
Classes: ErbScope
Constant Summary collapse
- EXTENSIONS =
{ 'text' => 'txt', 'soap' => 'xml', 'xoxo' => 'xml' }.freeze
Instance Attribute Summary collapse
-
#dryrun ⇒ Object
Returns the value of attribute dryrun.
-
#format ⇒ Object
Returns the value of attribute format.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#output ⇒ Object
Returns the value of attribute output.
-
#subtype ⇒ Object
Returns the value of attribute subtype.
-
#template ⇒ Object
Returns the value of attribute template.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(notes, options = {}) {|_self| ... } ⇒ Format
constructor
A new instance of Format.
- #render ⇒ Object
-
#render_custom ⇒ Object
C U S T O M.
-
#render_template ⇒ Object
T E M P L A T E.
Constructor Details
#initialize(notes, options = {}) {|_self| ... } ⇒ Format
Returns a new instance of Format.
33 34 35 36 37 38 39 40 41 |
# File 'lib/dnote/format.rb', line 33 def initialize(notes, = {}) @notes = notes @format = 'text' @subtype = 'label' @title = "Developer's Notes" @dryrun = false .each { |k, v| __send__("#{k}=", v) if v } yield(self) if block_given? end |
Instance Attribute Details
#dryrun ⇒ Object
Returns the value of attribute dryrun.
31 32 33 |
# File 'lib/dnote/format.rb', line 31 def dryrun @dryrun end |
#format ⇒ Object
Returns the value of attribute format.
21 22 23 |
# File 'lib/dnote/format.rb', line 21 def format @format end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
19 20 21 |
# File 'lib/dnote/format.rb', line 19 def notes @notes end |
#output ⇒ Object
Returns the value of attribute output.
25 26 27 |
# File 'lib/dnote/format.rb', line 25 def output @output end |
#subtype ⇒ Object
Returns the value of attribute subtype.
23 24 25 |
# File 'lib/dnote/format.rb', line 23 def subtype @subtype end |
#template ⇒ Object
Returns the value of attribute template.
27 28 29 |
# File 'lib/dnote/format.rb', line 27 def template @template end |
#title ⇒ Object
Returns the value of attribute title.
29 30 31 |
# File 'lib/dnote/format.rb', line 29 def title @title end |
Instance Method Details
#render ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dnote/format.rb', line 43 def render if notes.empty? $stderr << "No #{notes.labels.join(', ')} notes.\n" else case format when 'custom' render_custom else render_template end end end |
#render_custom ⇒ Object
C U S T O M
58 59 60 61 |
# File 'lib/dnote/format.rb', line 58 def render_custom result = erb(template) publish(result) end |
#render_template ⇒ Object
T E M P L A T E
65 66 67 68 69 70 71 |
# File 'lib/dnote/format.rb', line 65 def render_template template = File.join(File.dirname(__FILE__), 'templates', "#{format}.erb") raise "No such format - #{format}" unless File.exist?(template) result = erb(template) publish(result) end |