Class: NattyUI::Theme::Compiled
- Inherits:
-
Object
- Object
- NattyUI::Theme::Compiled
- Defined in:
- lib/natty-ui/theme.rb
Instance Attribute Summary collapse
-
#choice_current_style ⇒ Object
readonly
Returns the value of attribute choice_current_style.
-
#choice_style ⇒ Object
readonly
Returns the value of attribute choice_style.
-
#task_style ⇒ Object
readonly
Returns the value of attribute task_style.
Instance Method Summary collapse
- #border(value) ⇒ Object
- #defined_borders ⇒ Object
- #defined_marks ⇒ Object
- #heading(index) ⇒ Object
-
#initialize(theme) ⇒ Compiled
constructor
A new instance of Compiled.
- #mark(value) ⇒ Object
- #section_border(kind) ⇒ Object
Constructor Details
#initialize(theme) ⇒ Compiled
Returns a new instance of Compiled.
169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/natty-ui/theme.rb', line 169 def initialize(theme) @heading = create_heading(theme.heading, theme.heading_sytle).freeze @border = create_border(theme.border).freeze @mark = create_mark(theme.mark).freeze @task_style = as_style(theme.task_style) @choice_current_style = as_style(theme.choice_current_style) @choice_style = as_style(theme.choice_style) @sections = create_sections( SectionBorder.create(border(theme.section_border)), theme.section_styles.dup.compare_by_identity ) end |
Instance Attribute Details
#choice_current_style ⇒ Object (readonly)
Returns the value of attribute choice_current_style.
139 140 141 |
# File 'lib/natty-ui/theme.rb', line 139 def choice_current_style @choice_current_style end |
#choice_style ⇒ Object (readonly)
Returns the value of attribute choice_style.
139 140 141 |
# File 'lib/natty-ui/theme.rb', line 139 def choice_style @choice_style end |
#task_style ⇒ Object (readonly)
Returns the value of attribute task_style.
139 140 141 |
# File 'lib/natty-ui/theme.rb', line 139 def task_style @task_style end |
Instance Method Details
#border(value) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/natty-ui/theme.rb', line 151 def border(value) return @border[value] if value.is_a?(Symbol) case Text.width(value = value.to_s, bbcode: false) when 1 "#{value * 11} " when 11 "#{value} " when 13 value else @border[:default] end end |
#defined_borders ⇒ Object
142 |
# File 'lib/natty-ui/theme.rb', line 142 def defined_borders = @border.keys.sort! |
#defined_marks ⇒ Object
141 |
# File 'lib/natty-ui/theme.rb', line 141 def defined_marks = @mark.keys.sort! |
#heading(index) ⇒ Object
144 |
# File 'lib/natty-ui/theme.rb', line 144 def heading(index) = @heading[index.to_i.clamp(1, 6) - 1] |
#mark(value) ⇒ Object
146 147 148 149 |
# File 'lib/natty-ui/theme.rb', line 146 def mark(value) return @mark[value] if value.is_a?(Symbol) (element = Str.new(value, true)).empty? ? @mark[:default] : element end |
#section_border(kind) ⇒ Object
165 166 167 |
# File 'lib/natty-ui/theme.rb', line 165 def section_border(kind) kind.is_a?(Symbol) ? @sections[kind] : @sections[:default] end |