Class: NattyUI::Theme::Builder
- Inherits:
-
Object
- Object
- NattyUI::Theme::Builder
- Defined in:
- lib/natty-ui/theme.rb
Overview
This chapter needs more documentation.
Helper class to define a NattyUI::Theme.
Instance Attribute Summary collapse
-
#border ⇒ Object
readonly
Returns the value of attribute border.
-
#choice_current_style ⇒ Object
Returns the value of attribute choice_current_style.
-
#choice_style ⇒ Object
Returns the value of attribute choice_style.
-
#heading ⇒ Object
readonly
Returns the value of attribute heading.
-
#heading_sytle ⇒ Object
Returns the value of attribute heading_sytle.
-
#mark ⇒ Object
readonly
Returns the value of attribute mark.
-
#section_border ⇒ Object
Returns the value of attribute section_border.
-
#section_styles ⇒ Object
readonly
Returns the value of attribute section_styles.
-
#sh_err_style ⇒ Object
Returns the value of attribute sh_err_style.
-
#sh_out_style ⇒ Object
Returns the value of attribute sh_out_style.
-
#task_style ⇒ Object
Returns the value of attribute task_style.
Instance Method Summary collapse
-
#build ⇒ Theme
New theme.
- #define_border(**defs) ⇒ Object
- #define_heading(*defs) ⇒ Object
- #define_marker(**defs) ⇒ Object
- #define_section(**defs) ⇒ Object
Instance Attribute Details
#border ⇒ Object (readonly)
Returns the value of attribute border.
73 74 75 |
# File 'lib/natty-ui/theme.rb', line 73 def border @border end |
#choice_current_style ⇒ Object
Returns the value of attribute choice_current_style.
73 74 75 |
# File 'lib/natty-ui/theme.rb', line 73 def choice_current_style @choice_current_style end |
#choice_style ⇒ Object
Returns the value of attribute choice_style.
73 74 75 |
# File 'lib/natty-ui/theme.rb', line 73 def choice_style @choice_style end |
#heading ⇒ Object (readonly)
Returns the value of attribute heading.
73 74 75 |
# File 'lib/natty-ui/theme.rb', line 73 def heading @heading end |
#heading_sytle ⇒ Object
Returns the value of attribute heading_sytle.
73 74 75 |
# File 'lib/natty-ui/theme.rb', line 73 def heading_sytle @heading_sytle end |
#mark ⇒ Object (readonly)
Returns the value of attribute mark.
73 74 75 |
# File 'lib/natty-ui/theme.rb', line 73 def mark @mark end |
#section_border ⇒ Object
Returns the value of attribute section_border.
72 73 74 |
# File 'lib/natty-ui/theme.rb', line 72 def section_border @section_border end |
#section_styles ⇒ Object (readonly)
Returns the value of attribute section_styles.
73 74 75 |
# File 'lib/natty-ui/theme.rb', line 73 def section_styles @section_styles end |
#sh_err_style ⇒ Object
Returns the value of attribute sh_err_style.
73 74 75 |
# File 'lib/natty-ui/theme.rb', line 73 def sh_err_style @sh_err_style end |
#sh_out_style ⇒ Object
Returns the value of attribute sh_out_style.
73 74 75 |
# File 'lib/natty-ui/theme.rb', line 73 def sh_out_style @sh_out_style end |
#task_style ⇒ Object
Returns the value of attribute task_style.
73 74 75 |
# File 'lib/natty-ui/theme.rb', line 73 def task_style @task_style end |
Instance Method Details
#build ⇒ Theme
Returns new theme.
109 |
# File 'lib/natty-ui/theme.rb', line 109 def build = Theme.new(self) |
#define_border(**defs) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/natty-ui/theme.rb', line 116 def define_border(**defs) defs.each_pair do |name, str| s = str.to_s case Text.width(s, bbcode: false) when 1 @border[name.to_sym] = "#{s * 11} " when 11 @border[name.to_sym] = "#{s} " when 13 @border[name.to_sym] = s else raise( TypeError, "invalid boder definition for #{name} - #{str.inspect}" ) end end self end |
#define_heading(*defs) ⇒ Object
136 137 138 139 140 |
# File 'lib/natty-ui/theme.rb', line 136 def define_heading(*defs) @heading = defs.flatten.take(6) @heading += Array.new(6 - @heading.size, @heading[-1]) self end |
#define_marker(**defs) ⇒ Object
111 112 113 114 |
# File 'lib/natty-ui/theme.rb', line 111 def define_marker(**defs) @mark.merge!(defs) self end |
#define_section(**defs) ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/natty-ui/theme.rb', line 142 def define_section(**defs) defs.each_pair do |name, style| style = Utils.style(style) @section_styles[name.to_sym] = style if style end self end |