rasskey 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -2
- data/lib/rasskey/box.rb +11 -1
- data/lib/rasskey/version.rb +1 -1
- data/lib/rasskey.rb +2 -2
- metadata +4 -4
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
RassKey provides a few simple ASCII helpers for Ruby. Since this is the first release, the current functionality is fairly limited:
|
4
4
|
|
5
5
|
* RassKey::Box
|
6
|
-
* String
|
6
|
+
* String#to\_box helper
|
7
7
|
|
8
8
|
## RassKey::Box
|
9
9
|
|
@@ -47,7 +47,7 @@ These can either be set via an options hash passed to the _draw_ method or as se
|
|
47
47
|
* *
|
48
48
|
***************************************
|
49
49
|
|
50
|
-
## String
|
50
|
+
## String#to\_box
|
51
51
|
|
52
52
|
You can also use it as a String method:
|
53
53
|
|
data/lib/rasskey/box.rb
CHANGED
@@ -3,23 +3,28 @@ module RassKey
|
|
3
3
|
class << self
|
4
4
|
attr_accessor :default_padding
|
5
5
|
attr_accessor :default_glyph
|
6
|
+
attr_accessor :default_caption
|
6
7
|
|
7
8
|
end
|
8
9
|
|
9
10
|
@default_padding = 1
|
10
11
|
@default_glyph = '*'
|
12
|
+
@default_caption = nil
|
11
13
|
|
12
14
|
attr_accessor :padding
|
13
15
|
attr_accessor :glyph
|
16
|
+
attr_accessor :caption
|
14
17
|
|
15
18
|
def initialize(options = {})
|
16
19
|
options = {
|
17
20
|
:padding => RassKey::Box.default_padding,
|
18
|
-
:glyph => RassKey::Box.default_glyph
|
21
|
+
:glyph => RassKey::Box.default_glyph,
|
22
|
+
:caption => RassKey::Box.default_caption
|
19
23
|
}.merge(options)
|
20
24
|
|
21
25
|
self.padding = options[:padding]
|
22
26
|
self.glyph = options[:glyph]
|
27
|
+
self.caption = options[:caption]
|
23
28
|
|
24
29
|
super()
|
25
30
|
end
|
@@ -29,6 +34,7 @@ module RassKey
|
|
29
34
|
whitespace = " " * ( data.length + (@padding * 2) )
|
30
35
|
spacing = " " * @padding || " "
|
31
36
|
content_line = "#{@glyph}#{spacing}#{data}#{spacing}#{@glyph}"
|
37
|
+
caption_line = "#{spacing}#{@caption}#{spacing}"
|
32
38
|
top = @glyph * content_line.length
|
33
39
|
side = @glyph
|
34
40
|
bottom = @glyph * content_line.length
|
@@ -38,6 +44,10 @@ module RassKey
|
|
38
44
|
box << "#{content_line}"
|
39
45
|
(@padding/2).times { box << "#{@glyph}#{whitespace}#{@glyph}" }
|
40
46
|
box << bottom
|
47
|
+
unless @caption.nil?
|
48
|
+
caption_line = "(#{spacing}#{@caption}#{spacing})"
|
49
|
+
box << "#{caption_line}"
|
50
|
+
end
|
41
51
|
box.join("\n")
|
42
52
|
end
|
43
53
|
|
data/lib/rasskey/version.rb
CHANGED
data/lib/rasskey.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'rasskey/extensions/string'
|
2
|
+
require 'rasskey/box'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rasskey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- lusis
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-28 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|