Class: Vedeu::Cells::HTML Private

Inherits:
Object
  • Object
show all
Includes:
Vedeu::Common
Defined in:
lib/vedeu/cells/support/html.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.

Presents a Vedeu::Cells member class as a HTML string.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Vedeu::Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Constructor Details

#initialize(cell, options = {}) ⇒ Vedeu::Cells::HTML

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.

Parameters:

  • cell (void)

    The Vedeu::Cells class to be presented as HTML.

  • options (Hash) (defaults to: {})

    Options provided by Renderers::HTML.



20
21
22
23
# File 'lib/vedeu/cells/support/html.rb', line 20

def initialize(cell, options = {})
  @cell    = cell
  @options = options || {}
end

Instance Attribute Details

#cellVedeu::Cells (readonly, protected)

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.

Returns:



34
35
36
# File 'lib/vedeu/cells/support/html.rb', line 34

def cell
  @cell
end

#optionsHash (readonly, protected)

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.

Returns:

  • (Hash)


38
39
40
# File 'lib/vedeu/cells/support/html.rb', line 38

def options
  @options
end

Instance Method Details

#backgroundString (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.

Returns:

  • (String)


43
44
45
46
47
# File 'lib/vedeu/cells/support/html.rb', line 43

def background
  return '' unless cell.respond_to?(:background)

  cell.background.to_html
end

#end_tagString (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.

Returns:

  • (String)


50
51
52
# File 'lib/vedeu/cells/support/html.rb', line 50

def end_tag
  options.fetch(:end_tag, '</td>')
end

#foregroundString (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.

Returns:

  • (String)


55
56
57
58
59
# File 'lib/vedeu/cells/support/html.rb', line 55

def foreground
  return '' unless cell.respond_to?(:foreground)

  cell.foreground.to_html
end

#start_tagString (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.

Returns:

  • (String)


62
63
64
# File 'lib/vedeu/cells/support/html.rb', line 62

def start_tag
  options.fetch(:start_tag, '<td')
end

#style_attributeString (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.

Returns:

  • (String)


67
68
69
70
71
# File 'lib/vedeu/cells/support/html.rb', line 67

def style_attribute
  return '' if absent?(background) && absent?(foreground)

  " style='#{background}#{foreground}'"
end

#to_htmlString

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.

Returns:

  • (String)


26
27
28
# File 'lib/vedeu/cells/support/html.rb', line 26

def to_html
  "#{start_tag}#{style_attribute}>#{value}#{end_tag}"
end

#valueString (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.

Returns:

  • (String)


74
75
76
77
78
79
80
81
82
# File 'lib/vedeu/cells/support/html.rb', line 74

def value
  if cell.respond_to?(:as_html) && present?(cell.as_html)
    cell.as_html

  else
    '&nbsp;'

  end
end