Class: Vedeu::Views::HTMLChar
- Inherits:
-
Object
- Object
- Vedeu::Views::HTMLChar
- Includes:
- Common
- Defined in:
- lib/vedeu/models/views/html_char.rb
Overview
Represents a Char as a HTML tag with value. By default, a table cell is used.
Instance Attribute Summary collapse
- #char ⇒ Vedeu::Views::Char readonly protected
Class Method Summary collapse
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
- #border ⇒ Symbol|NilClass private
- #border_style ⇒ String private
- #css(direction) ⇒ String private
- #defaults ⇒ Hash<Symbol => String> private
-
#demodulize(klass) ⇒ String
included
from Common
private
Removes the module part from the expression in the string.
- #end_tag ⇒ String private
-
#initialize(char, options = {}) ⇒ Vedeu::Views::HTMLChar
constructor
Returns a new instance of Vedeu::Views::HTMLChar.
- #options ⇒ Hash<Symbol => String> private
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
- #render ⇒ String
-
#snake_case(name) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
- #start_tag ⇒ String private
- #tag_style ⇒ String private
- #tag_style_background ⇒ String private
- #tag_style_foreground ⇒ String private
- #tag_value ⇒ String private
- #value ⇒ String private
Constructor Details
#initialize(char, options = {}) ⇒ Vedeu::Views::HTMLChar
Returns a new instance of Vedeu::Views::HTMLChar.
25 26 27 28 |
# File 'lib/vedeu/models/views/html_char.rb', line 25 def initialize(char, = {}) @char = char = end |
Instance Attribute Details
#char ⇒ Vedeu::Views::Char (readonly, protected)
39 40 41 |
# File 'lib/vedeu/models/views/html_char.rb', line 39 def char @char end |
Class Method Details
.render(char, options = {}) ⇒ String
14 15 16 |
# File 'lib/vedeu/models/views/html_char.rb', line 14 def self.render(char, = {}) new(char, ).render end |
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module 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.
#border ⇒ Symbol|NilClass (private)
94 95 96 |
# File 'lib/vedeu/models/views/html_char.rb', line 94 def border char.border end |
#border_style ⇒ String (private)
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/vedeu/models/views/html_char.rb', line 72 def border_style case border when :top_horizontal then css(:top) when :left_vertical then css(:left) when :right_vertical then css(:right) when :bottom_horizontal then css(:bottom) when :top_left then "#{css(:top)}#{css(:left)}".freeze when :top_right then "#{css(:top)}#{css(:right)}".freeze when :bottom_left then "#{css(:bottom)}#{css(:left)}".freeze when :bottom_right then "#{css(:bottom)}#{css(:right)}".freeze else '' end end |
#css(direction) ⇒ String (private)
89 90 91 |
# File 'lib/vedeu/models/views/html_char.rb', line 89 def css(direction) "border-#{direction}:1px #{char.foreground.to_html} solid;".freeze end |
#defaults ⇒ Hash<Symbol => String> (private)
119 120 121 122 123 124 |
# File 'lib/vedeu/models/views/html_char.rb', line 119 def defaults { start_tag: '<td', end_tag: '</td>', } end |
#demodulize(klass) ⇒ String Originally defined in module 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.
Removes the module part from the expression in the string.
#end_tag ⇒ String (private)
109 110 111 |
# File 'lib/vedeu/models/views/html_char.rb', line 109 def end_tag [:end_tag] end |
#options ⇒ Hash<Symbol => String> (private)
114 115 116 |
# File 'lib/vedeu/models/views/html_char.rb', line 114 def defaults.merge!() end |
#present?(variable) ⇒ Boolean Originally defined in module 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.
#render ⇒ String
31 32 33 |
# File 'lib/vedeu/models/views/html_char.rb', line 31 def render "#{start_tag}#{tag_style}>#{tag_value}#{end_tag}".freeze end |
#snake_case(name) ⇒ String Originally defined in module 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.
#start_tag ⇒ String (private)
104 105 106 |
# File 'lib/vedeu/models/views/html_char.rb', line 104 def start_tag [:start_tag] end |
#tag_style ⇒ String (private)
44 45 46 47 48 49 50 51 |
# File 'lib/vedeu/models/views/html_char.rb', line 44 def tag_style return '' unless border || present?(value) out = " style='" out << tag_style_background unless char.background.empty? out << tag_style_foreground unless char.foreground.empty? out << "'".freeze end |
#tag_style_background ⇒ String (private)
54 55 56 57 |
# File 'lib/vedeu/models/views/html_char.rb', line 54 def tag_style_background "border:1px #{char.background.to_html} solid;" \ "background:#{char.background.to_html};".freeze end |
#tag_style_foreground ⇒ String (private)
60 61 62 |
# File 'lib/vedeu/models/views/html_char.rb', line 60 def tag_style_foreground "color:#{char.foreground.to_html};#{border_style}".freeze end |
#tag_value ⇒ String (private)
65 66 67 68 69 |
# File 'lib/vedeu/models/views/html_char.rb', line 65 def tag_value return ' '.freeze if border || !present?(value) value end |
#value ⇒ String (private)
99 100 101 |
# File 'lib/vedeu/models/views/html_char.rb', line 99 def value char.value end |