Class: AsciiPaint::Config
- Inherits:
-
Object
- Object
- AsciiPaint::Config
- Defined in:
- lib/ascii_paint/config.rb
Defined Under Namespace
Modules: Default
Instance Attribute Summary collapse
-
#character_height ⇒ Object
The vertical size in pixels of the rectangle that replaces a single character during painting.
-
#character_width ⇒ Object
The horizontal size in pixels of the rectangle that replaces a single character during painting.
-
#color_map ⇒ Object
Returns the value of attribute color_map.
Instance Method Summary collapse
- #border_color ⇒ Object
- #characters_to_pixels(x, y) ⇒ Object
-
#color_for_undefined_character=(default_color) ⇒ void
Set the color to paint over characters whose color hasn’t been defined by the color map.
-
#initialize(settings = {}) ⇒ Config
constructor
A new instance of Config.
- #reset! ⇒ Object
-
#set_options(options) ⇒ Object
Set configuration options using a hash instead of using method calls.
Constructor Details
#initialize(settings = {}) ⇒ Config
Returns a new instance of Config.
24 25 26 27 |
# File 'lib/ascii_paint/config.rb', line 24 def initialize(settings = {}) reset! (settings) end |
Instance Attribute Details
#character_height ⇒ Object
The vertical size in pixels of the rectangle that replaces a single character during painting.
20 21 22 |
# File 'lib/ascii_paint/config.rb', line 20 def character_height @character_height end |
#character_width ⇒ Object
The horizontal size in pixels of the rectangle that replaces a single character during painting.
16 17 18 |
# File 'lib/ascii_paint/config.rb', line 16 def character_width @character_width end |
#color_map ⇒ Object
Returns the value of attribute color_map.
22 23 24 |
# File 'lib/ascii_paint/config.rb', line 22 def color_map @color_map end |
Instance Method Details
#border_color ⇒ Object
78 79 80 |
# File 'lib/ascii_paint/config.rb', line 78 def border_color TRANSPARENT end |
#characters_to_pixels(x, y) ⇒ Object
57 58 59 |
# File 'lib/ascii_paint/config.rb', line 57 def characters_to_pixels(x, y) [x * character_width, y * character_height] end |
#color_for_undefined_character=(default_color) ⇒ void
This method returns an undefined value.
Set the color to paint over characters whose color hasn’t been defined by the color map.
53 54 55 |
# File 'lib/ascii_paint/config.rb', line 53 def color_for_undefined_character=(default_color) color_map.default = replacement_for_special_symbol(default_color) end |
#reset! ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ascii_paint/config.rb', line 82 def reset! @character_height = Default::CHARACTER_HEIGHT @character_width = Default::CHARACTER_WIDTH @color_map = begin map = Default::COLOR_MAP.dup map.default = Default::COLOR_FOR_UNDEFINED_CHARACTER replace_special_symbols!(map) map end end |
#set_options(options) ⇒ Object
Set configuration options using a hash instead of using method calls. For example,
config.({character_width: 10})
is equivalent to
config.character_width = 10
70 71 72 73 74 75 76 |
# File 'lib/ascii_paint/config.rb', line 70 def () .each do |key, value| mutator_name = "#{key}=" self.send(mutator_name, value) end self end |