Class: Lotus::Helpers::HtmlHelper::EmptyHtmlNode Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/helpers/html_helper/empty_html_node.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.

Empty HTML node

Since:

  • 0.1.0

Direct Known Subclasses

HtmlNode

Constant Summary collapse

ATTRIBUTES_SEPARATOR =

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

Attributes separator

Since:

  • 0.1.0

' '.freeze

Instance Method Summary collapse

Constructor Details

#initialize(name, attributes) ⇒ Lotus::Helpers::HtmlHelper::EmptyHtmlNode

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 a new empty HTML node

Parameters:

  • name (Symbol, String)

    the name of the tag

  • attributes (Hash, NilClass)

    the optional tag attributes

Since:

  • 0.1.0


24
25
26
27
# File 'lib/lotus/helpers/html_helper/empty_html_node.rb', line 24

def initialize(name, attributes)
  @name       = name
  @attributes = attributes
end

Instance Method Details

#attributesString, NilClass (private)

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.

Resolve the attributes

Returns:

  • (String, NilClass)

    the tag attributes

Since:

  • 0.1.0


46
47
48
49
50
51
52
53
54
55
# File 'lib/lotus/helpers/html_helper/empty_html_node.rb', line 46

def attributes
  return if @attributes.nil?
  result = [nil]

  @attributes.each do |name, value|
    result << %(#{ name }="#{ value }")
  end

  result.join(ATTRIBUTES_SEPARATOR)
end

#to_sString

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.

Resolve and return the output

Returns:

  • (String)

    the output

Since:

  • 0.1.0


35
36
37
# File 'lib/lotus/helpers/html_helper/empty_html_node.rb', line 35

def to_s
  %(<#{ @name }#{attributes}>)
end