Class: RassKey::Line
- Inherits:
-
Object
- Object
- RassKey::Line
- Defined in:
- lib/rasskey/line.rb
Class Attribute Summary collapse
-
.default_glyph ⇒ Object
Returns the value of attribute default_glyph.
-
.default_length ⇒ Object
Returns the value of attribute default_length.
-
.default_orientation ⇒ Object
Returns the value of attribute default_orientation.
-
.default_padding ⇒ Object
Returns the value of attribute default_padding.
Instance Attribute Summary collapse
-
#glyph ⇒ Object
Returns the value of attribute glyph.
-
#line_length ⇒ Object
Returns the value of attribute line_length.
-
#orientation ⇒ Object
Returns the value of attribute orientation.
-
#padding ⇒ Object
Returns the value of attribute padding.
Instance Method Summary collapse
- #draw(data) ⇒ Object
-
#initialize(options = {}) ⇒ Line
constructor
A new instance of Line.
- #vertical(data) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Line
Returns a new instance of Line.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rasskey/line.rb', line 20 def initialize( = {}) = { :line_length => RassKey::Line.default_length, :padding => RassKey::Line.default_padding, :glyph => RassKey::Line.default_glyph, :orientation => RassKey::Line.default_orientation }.merge() self.line_length = [:line_length] self.padding = [:padding] self.glyph = [:glyph] self.orientation = [:orientation] super() end |
Class Attribute Details
.default_glyph ⇒ Object
Returns the value of attribute default_glyph.
6 7 8 |
# File 'lib/rasskey/line.rb', line 6 def default_glyph @default_glyph end |
.default_length ⇒ Object
Returns the value of attribute default_length.
4 5 6 |
# File 'lib/rasskey/line.rb', line 4 def default_length @default_length end |
.default_orientation ⇒ Object
Returns the value of attribute default_orientation.
7 8 9 |
# File 'lib/rasskey/line.rb', line 7 def default_orientation @default_orientation end |
.default_padding ⇒ Object
Returns the value of attribute default_padding.
5 6 7 |
# File 'lib/rasskey/line.rb', line 5 def default_padding @default_padding end |
Instance Attribute Details
#glyph ⇒ Object
Returns the value of attribute glyph.
17 18 19 |
# File 'lib/rasskey/line.rb', line 17 def glyph @glyph end |
#line_length ⇒ Object
Returns the value of attribute line_length.
15 16 17 |
# File 'lib/rasskey/line.rb', line 15 def line_length @line_length end |
#orientation ⇒ Object
Returns the value of attribute orientation.
18 19 20 |
# File 'lib/rasskey/line.rb', line 18 def orientation @orientation end |
#padding ⇒ Object
Returns the value of attribute padding.
16 17 18 |
# File 'lib/rasskey/line.rb', line 16 def padding @padding end |
Instance Method Details
#draw(data) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rasskey/line.rb', line 36 def draw(data) @glyph.length == 1 ? (@glyph = @glyph) : (@glyph = @glyph[0,1]) spacing = " " * @padding || " " line_text = "#{spacing}#{data}#{spacing}" begin content_line = "#{@glyph * ((@line_length - line_text.length)/2)}#{line_text}#{@glyph * ((@line_length - line_text.length)/2)}" rescue puts "line length must be larger to accomodate text" end case @orientation when "horizontal" content_line when "vertical" self.vertical(content_line) else puts "unknown orientation. Should be vertical or horizontal" end end |
#vertical(data) ⇒ Object
55 56 57 |
# File 'lib/rasskey/line.rb', line 55 def vertical(data) data.split(//).join("\n") end |