box_puts 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/box_puts.rb +32 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NzIxYjg5MjJjZGE2ODU4MzcxZGVkZWYwZDk3ODc3Y2ZhN2I4ZTcwYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDdjNjJlZGZkYTg5YTYxMWU0N2U2NTE2MmUwYzEwZWMwNjAyYmExZQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NmUxOWYzNmMyMDExN2JiZTMzNjlkMDBjYTgxNmRiZTMyY2ZkMTUyYjgzZmM1
|
10
|
+
OTlkZGRhNzcxNzNhZDc0OGM4OTM5OWVjOTA1YzRhYTFiY2VjMjRiMWJmMGI1
|
11
|
+
YThkYTgzOWUyM2EwYTZiNzgzMDE0OTU5OWIzN2IyMWVhZDgwY2U=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjhlMDAzY2M3MWY4YzA5MjJiYjEwN2U3ODlmYzA2ZjEyNDllMTJhNDNhZDA0
|
14
|
+
NjJmYjdkMDU0M2Y4NzM4NTcyZTZjODdhNmJiYjYzNjQ0MTlkNjYzNGI3YWY4
|
15
|
+
YmRjNjc4ZmU3N2QzZWUyZWM3MjllYjJmNmJhMTQzYjJlOWNjMjM=
|
data/lib/box_puts.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# @author Jonathan Raiman
|
3
|
+
|
4
|
+
module BoxPuts
|
5
|
+
# Output a boxed set of text, specifiy alignment, and place a title above the box.
|
6
|
+
#
|
7
|
+
# @param opts [Hash] parameters for the box with the text
|
8
|
+
# @option opts [Fixnum] :width How wide to draw the box. Defaults to 70 characters.
|
9
|
+
# @option opts [String] :align Text alignment within the box: `left`, `center`, or `right`. Defaults to `left`.
|
10
|
+
# @option opts [String] :title An optional title to place above the box.
|
11
|
+
# @option opts [Array<String>] :lines An array of lines to output inside the box.
|
12
|
+
def self.show(opts={})
|
13
|
+
width, title, align = opts[:width] || 70, opts[:title], opts[:align] || "left"
|
14
|
+
lines = ["┌"+(title ? (("─"*5)+"[#{title[0..(width-10)]}]"+(width-9-title.length > 0 ? ("─"*(width-9-title.length)) : "")) : "─"*(width-2))+"┐"]
|
15
|
+
opts[:lines].each do |line|
|
16
|
+
text = "│"
|
17
|
+
if align == "left" or line.length > width-3
|
18
|
+
text += " "+line[0..(width-4)]+((width-3-line.length) > 0 ? (" "*(width-3-line.length)) : "")
|
19
|
+
elsif align == "center"
|
20
|
+
rem_width = width-2-(width-3-line.length)/2-line[0..(width-4)].length-(width-2-line.length)/2
|
21
|
+
text += (" "*((width-3-line.length)/2))+line[0..(width-4)]+(" "*((width-2-line.length)/2))
|
22
|
+
if rem_width > 0 then text += " "*rem_width end
|
23
|
+
else
|
24
|
+
text += (" "*(width-3-line.length))+line[0..(width-4)]+" "
|
25
|
+
end
|
26
|
+
text += "│"
|
27
|
+
lines << text
|
28
|
+
end
|
29
|
+
lines << ("└"+("─"*(width-2))+"┘")
|
30
|
+
puts lines
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: box_puts
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Raiman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Output text in a framed box, with a title.
|
14
|
+
email: jraiman@mit.edu
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/box_puts.rb
|
20
|
+
homepage: http://github.org/JonathanRaiman/box_puts
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.1.10
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Output text in a framed box, with a title.
|
44
|
+
test_files: []
|
45
|
+
has_rdoc: yard
|