Class: Brandish::Processors::HTML::Output::Document Private

Inherits:
Object
  • Object
show all
Defined in:
lib/brandish/processors/html/output/document.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A "document." This contains meta information for the document, such as the title, author, description, styles, and scripts that are used to set up the HTML document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDocument

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize the document.



30
31
32
33
34
35
36
# File 'lib/brandish/processors/html/output/document.rb', line 30

def initialize
  @title = ""
  @author = ""
  @description = ""
  @styles = []
  @scripts = []
end

Instance Attribute Details

#author::String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The author for the document. This is used for a <meta> tag.

Returns:

  • (::String, nil)


22
23
24
# File 'lib/brandish/processors/html/output/document.rb', line 22

def author
  @author
end

#description::String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The description of the document. This is used for a <meta> tag.

Returns:

  • (::String, nil)


27
28
29
# File 'lib/brandish/processors/html/output/document.rb', line 27

def description
  @description
end

#title::String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The title of the document. This is used for the <title> tag.

Returns:

  • (::String, nil)


17
18
19
# File 'lib/brandish/processors/html/output/document.rb', line 17

def title
  @title
end

Instance Method Details

#add_inline_script(content) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds an inline script.

Parameters:

  • content (::String)

    The script itself.

Returns:

  • (self)

See Also:



101
102
103
# File 'lib/brandish/processors/html/output/document.rb', line 101

def add_inline_script(content)
  add_script(:inline, content)
end

#add_inline_style(content) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds an inline style.

Parameters:

  • content (::String)

    The stylesheet itself.

Returns:

  • (self)

See Also:



83
84
85
# File 'lib/brandish/processors/html/output/document.rb', line 83

def add_inline_style(content)
  add_style(:inline, content)
end

#add_linked_script(content) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds an linked script.

Parameters:

  • content (::String)

    The link to the script.

Returns:

  • (self)

See Also:



110
111
112
# File 'lib/brandish/processors/html/output/document.rb', line 110

def add_linked_script(content)
  add_script(:linked, URI.escape(content.to_s))
end

#add_linked_style(content) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds an linked style.

Parameters:

  • content (::String)

    The link to the stylesheet.

Returns:

  • (self)

See Also:



92
93
94
# File 'lib/brandish/processors/html/output/document.rb', line 92

def add_linked_style(content)
  add_style(:linked, URI.escape(content.to_s))
end

#add_script(type, content) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds a given script with the given type. The type of the kind of script it is; this should be either one of :inline or :linked.

Parameters:

  • type (::Symbol)

    The style type.

  • content (::String)

    The contents of the script. For an inline style, this is the script it self; for a linked script, this is the link to the script.

Returns:

  • (self)


66
67
68
69
70
71
72
73
74
75
76
# File 'lib/brandish/processors/html/output/document.rb', line 66

def add_script(type, content)
  inline = type == :inline
  linked = type == :linked

  @scripts << {
    "inline?" => inline,
    "linked?" => linked,
    "content" => content.to_s
  }
  self
end

#add_style(type, content) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds a given style with the given type. The type is the kind of style it is; this should be either one of :inline or :linked.

Parameters:

  • type (::Symbol)

    The style type.

  • content (::String)

    The contents of the style. For an inline style, this is the stylesheet itself; for a linked style, this is the link to the stylesheet.

Returns:

  • (self)


46
47
48
49
50
51
52
53
54
55
56
# File 'lib/brandish/processors/html/output/document.rb', line 46

def add_style(type, content)
  inline = type == :inline
  linked = type == :linked

  @styles << {
    "inline?" => inline,
    "linked?" => linked,
    "content" => content.to_s
  }
  self
end

#data::Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The data from this document. This is used to pass all of the proper information to the templating library.

Returns:

  • (::Object)


118
119
120
121
122
# File 'lib/brandish/processors/html/output/document.rb', line 118

def data
  { "title" => @title, "author" => @author,
    "description" => @description,
    "styles" => @styles, "scripts" => @scripts }.freeze
end