Class: AsciiPaint::BlockCharacter
- Inherits:
-
Object
- Object
- AsciiPaint::BlockCharacter
- Defined in:
- lib/ascii_paint/block_character.rb
Constant Summary collapse
- UNPADDED_HEIGHT =
TODO: make customizable
5
- UNPADDED_WIDTH =
5
- VERTICAL_PADDING =
2
- HORIZONTAL_PADDING =
2
Instance Attribute Summary collapse
-
#ascii ⇒ Object
readonly
Returns the value of attribute ascii.
Class Method Summary collapse
- .bottom_padding ⇒ Object
- .height ⇒ Object
- .left_padding ⇒ Object
- .right_padding ⇒ Object
- .top_padding ⇒ Object
- .width ⇒ Object
Instance Method Summary collapse
-
#initialize(character) ⇒ BlockCharacter
constructor
A new instance of BlockCharacter.
- #newline? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(character) ⇒ BlockCharacter
Returns a new instance of BlockCharacter.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ascii_paint/block_character.rb', line 11 def initialize(character) raise "Only single characters please! #{character}" unless character.size == 1 if character == "\n" @newline = true return end load_ascii(character) end |
Instance Attribute Details
#ascii ⇒ Object (readonly)
Returns the value of attribute ascii.
3 4 5 |
# File 'lib/ascii_paint/block_character.rb', line 3 def ascii @ascii end |
Class Method Details
.bottom_padding ⇒ Object
50 51 52 |
# File 'lib/ascii_paint/block_character.rb', line 50 def self.bottom_padding (VERTICAL_PADDING + 1) / 2 end |
.height ⇒ Object
30 31 32 |
# File 'lib/ascii_paint/block_character.rb', line 30 def self.height UNPADDED_HEIGHT + VERTICAL_PADDING end |
.left_padding ⇒ Object
38 39 40 |
# File 'lib/ascii_paint/block_character.rb', line 38 def self.left_padding HORIZONTAL_PADDING / 2 end |
.right_padding ⇒ Object
42 43 44 |
# File 'lib/ascii_paint/block_character.rb', line 42 def self.right_padding (HORIZONTAL_PADDING + 1) / 2 end |
.top_padding ⇒ Object
46 47 48 |
# File 'lib/ascii_paint/block_character.rb', line 46 def self.top_padding VERTICAL_PADDING / 2 end |
.width ⇒ Object
34 35 36 |
# File 'lib/ascii_paint/block_character.rb', line 34 def self.width UNPADDED_WIDTH + HORIZONTAL_PADDING end |
Instance Method Details
#newline? ⇒ Boolean
22 23 24 |
# File 'lib/ascii_paint/block_character.rb', line 22 def newline? !!@newline end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/ascii_paint/block_character.rb', line 26 def to_s ascii.join("\n") end |