Class: DNote::Format

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(notes, format: "text", title: "Developer's Notes", template: nil, output: nil, dryrun: false) ⇒ Format

Returns a new instance of Format.



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dnote/format.rb', line 21

def initialize(notes,
               format: "text",
               title: "Developer's Notes",
               template: nil,
               output: nil,
               dryrun: false)
  @notes = notes
  @format = format
  @title = title
  @dryrun = dryrun
  @template = template
  @output = output
end

Instance Attribute Details

#dryrunObject (readonly)

Returns the value of attribute dryrun.



19
20
21
# File 'lib/dnote/format.rb', line 19

def dryrun
  @dryrun
end

#formatObject (readonly)

Returns the value of attribute format.



19
20
21
# File 'lib/dnote/format.rb', line 19

def format
  @format
end

#notesObject (readonly)

Returns the value of attribute notes.



19
20
21
# File 'lib/dnote/format.rb', line 19

def notes
  @notes
end

#outputObject (readonly)

Returns the value of attribute output.



19
20
21
# File 'lib/dnote/format.rb', line 19

def output
  @output
end

#templateObject (readonly)

Returns the value of attribute template.



19
20
21
# File 'lib/dnote/format.rb', line 19

def template
  @template
end

#titleObject (readonly)

Returns the value of attribute title.



19
20
21
# File 'lib/dnote/format.rb', line 19

def title
  @title
end

Instance Method Details

#renderObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dnote/format.rb', line 35

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