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

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.



18
19
20
21
# File 'lib/vedeu/cells/support/html.rb', line 18

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

Instance Attribute Details

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

This method returns an undefined value.



32
33
34
# File 'lib/vedeu/cells/support/html.rb', line 32

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)


36
37
38
# File 'lib/vedeu/cells/support/html.rb', line 36

def options
  @options
end

Instance Method Details

#absent?(variable) ⇒ Boolean Originally defined in module Vedeu::Common

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 a boolean indicating whether a variable is nil or empty.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

#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)


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

def background
  if cell.respond_to?(:background)
    cell.background.to_html

  else
    ''

  end
end

#become(klass, attributes) ⇒ Class Originally defined in module Vedeu::Common

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.

Converts one class into another.

Parameters:

  • klass (Class)

    The class to become an instance of.

  • attributes (Hash)

    The attributes of klass.

Returns:

  • (Class)

    Returns a new instance of klass.

#boolean(value) ⇒ Boolean Originally defined in module Vedeu::Common

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 a boolean indicating the value was a boolean.

Parameters:

  • value (void)

Returns:

#boolean?(value) ⇒ Boolean Originally defined in module Vedeu::Common

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 a boolean indicating whether the value is a Boolean.

Parameters:

Returns:

#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)


52
53
54
# File 'lib/vedeu/cells/support/html.rb', line 52

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

#escape?(value) ⇒ Boolean Originally defined in module Vedeu::Common

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 a boolean indicating whether the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)

Returns:

#falsy?(value) ⇒ Boolean Originally defined in module Vedeu::Common

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 a boolean indicating whether the value should be considered false.

Parameters:

  • value (void)

Returns:

#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)


57
58
59
60
61
62
63
64
65
# File 'lib/vedeu/cells/support/html.rb', line 57

def foreground
  if cell.respond_to?(:foreground)
    cell.foreground.to_html

  else
    ''

  end
end

#hash?(value) ⇒ Boolean Originally defined in module Vedeu::Common

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 a boolean indicating whether the value is a Hash.

Parameters:

  • value (Hash|void)

Returns:

#line_model?Boolean Originally defined in module Vedeu::Common

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 a boolean indicating the model is a Views::Line.

Returns:

#numeric?(value) ⇒ Boolean Originally defined in module Vedeu::Common

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 a boolean indicating whether the value is a Fixnum.

Parameters:

  • value (Fixnum|void)

Returns:

#present?(variable) ⇒ Boolean Originally defined in module Vedeu::Common

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 a boolean indicating whether a variable has a useful value.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

#snake_case(klass) ⇒ String Originally defined in module Vedeu::Common

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.

Converts a class name to a lowercase snake case string.

Examples:

snake_case(MyClassName) # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

snake_case('MyClassName') # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

Parameters:

  • klass (Module|Class|String)

Returns:

  • (String)

#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)


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

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

#stream_model?Boolean Originally defined in module Vedeu::Common

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 a boolean indicating the model is a Views::Stream.

Returns:

#string?(value) ⇒ Boolean Originally defined in module Vedeu::Common

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 a boolean indicating whether the value is a Fixnum.

Parameters:

  • value (String|void)

Returns:

#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)


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

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

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

  end
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)


24
25
26
# File 'lib/vedeu/cells/support/html.rb', line 24

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

#truthy?(value) ⇒ Boolean Originally defined in module Vedeu::Common

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 a boolean indicating whether the value should be considered true.

Parameters:

  • value (void)

Returns:

#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)


84
85
86
87
88
89
90
91
92
# File 'lib/vedeu/cells/support/html.rb', line 84

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

  else
    '&nbsp;'

  end
end

#view_model?Boolean Originally defined in module Vedeu::Common

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 a boolean indicating the model is a Views::View.

Returns: