Class: Vedeu::HTMLChar
- Inherits:
-
Object
- Object
- Vedeu::HTMLChar
- Includes:
- Common
- Defined in:
- lib/vedeu/output/html_char.rb
Overview
Represents a Char as a HTML table cell.
Instance Attribute Summary collapse
- #char ⇒ Vedeu::Char readonly protected
Class Method Summary collapse
Instance Method Summary collapse
- #bg ⇒ String private
- #border ⇒ Symbol|NilClass private
- #border_style ⇒ String private
- #colour_bg ⇒ String private
- #colour_fg ⇒ String private
- #css(direction = '') ⇒ String private
- #fg ⇒ String private
-
#initialize(char) ⇒ Vedeu::HTMLChar
constructor
Returns a new instance of Vedeu::HTMLChar.
- #render ⇒ String
- #td_style ⇒ String private
- #td_value ⇒ String private
- #value ⇒ String private
Methods included from Common
Constructor Details
#initialize(char) ⇒ Vedeu::HTMLChar
Returns a new instance of Vedeu::HTMLChar.
20 21 22 |
# File 'lib/vedeu/output/html_char.rb', line 20 def initialize(char) @char = char end |
Instance Attribute Details
#char ⇒ Vedeu::Char (readonly, protected)
33 34 35 |
# File 'lib/vedeu/output/html_char.rb', line 33 def char @char end |
Class Method Details
.render(char) ⇒ String
12 13 14 |
# File 'lib/vedeu/output/html_char.rb', line 12 def self.render(char) new(char).render end |
Instance Method Details
#bg ⇒ String (private)
82 83 84 |
# File 'lib/vedeu/output/html_char.rb', line 82 def bg @bg ||= colour_bg end |
#border ⇒ Symbol|NilClass (private)
115 116 117 |
# File 'lib/vedeu/output/html_char.rb', line 115 def border char.border end |
#border_style ⇒ String (private)
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/vedeu/output/html_char.rb', line 56 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')].join when :top_right then [css('top'), css('right')].join when :bottom_left then [css('bottom'), css('left')].join when :bottom_right then [css('bottom'), css('right')].join else '' end end |
#colour_bg ⇒ String (private)
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/vedeu/output/html_char.rb', line 87 def colour_bg if defined_value?(char.background.to_html) char.background.to_html elsif defined_value?(char.parent_background.to_html) char.parent_background.to_html else '#000' end end |
#colour_fg ⇒ String (private)
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/vedeu/output/html_char.rb', line 101 def colour_fg if defined_value?(char.foreground.to_html) char.foreground.to_html elsif defined_value?(char.parent_foreground.to_html) char.parent_foreground.to_html else '#222' end end |
#css(direction = '') ⇒ String (private)
72 73 74 |
# File 'lib/vedeu/output/html_char.rb', line 72 def css(direction = '') "border-#{direction}:1px #{fg} solid;" end |
#fg ⇒ String (private)
77 78 79 |
# File 'lib/vedeu/output/html_char.rb', line 77 def fg @fg ||= colour_fg end |
#render ⇒ String
25 26 27 |
# File 'lib/vedeu/output/html_char.rb', line 25 def render "<td#{td_style}>#{td_value}</td>" end |
#td_style ⇒ String (private)
38 39 40 41 42 43 44 45 46 |
# File 'lib/vedeu/output/html_char.rb', line 38 def td_style return '' unless border || defined_value?(value) " style='" \ "background:#{bg};" \ "color:#{fg};" \ "border:1px #{bg} solid;" \ "#{border_style}'" end |
#td_value ⇒ String (private)
49 50 51 52 53 |
# File 'lib/vedeu/output/html_char.rb', line 49 def td_value return ' ' if border || !defined_value?(value) value end |
#value ⇒ String (private)
120 121 122 |
# File 'lib/vedeu/output/html_char.rb', line 120 def value char.value end |