Class: NattyUI::Theme::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/natty-ui/theme.rb

Overview

TODO:

This chapter needs more documentation.

Helper class to define a NattyUI::Theme.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#borderObject (readonly)

Returns the value of attribute border.



73
74
75
# File 'lib/natty-ui/theme.rb', line 73

def border
  @border
end

#choice_current_styleObject

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_styleObject

Returns the value of attribute choice_style.



73
74
75
# File 'lib/natty-ui/theme.rb', line 73

def choice_style
  @choice_style
end

#headingObject (readonly)

Returns the value of attribute heading.



73
74
75
# File 'lib/natty-ui/theme.rb', line 73

def heading
  @heading
end

#heading_sytleObject

Returns the value of attribute heading_sytle.



73
74
75
# File 'lib/natty-ui/theme.rb', line 73

def heading_sytle
  @heading_sytle
end

#markObject (readonly)

Returns the value of attribute mark.



73
74
75
# File 'lib/natty-ui/theme.rb', line 73

def mark
  @mark
end

#section_borderObject

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_stylesObject (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_styleObject

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_styleObject

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_styleObject

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

#buildTheme

Returns new theme.

Returns:



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