pictureframe 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e699fb29f004c65cd761365dde899a871226c9a
4
- data.tar.gz: a1678ca99b7470646dc009f9e462621a12ba66ea
3
+ metadata.gz: 7b0d5f6e631e764e52b54242e1e0beeeb9836945
4
+ data.tar.gz: 4aa40e50a350c31a896f056d7c182c18c429c5f8
5
5
  SHA512:
6
- metadata.gz: 0d802f43d45bdafe8c43526b9abef14c1e8cfc84da248cef907a2a877f71e9ea4d94a3e84c9682a1e189c5383ae1e9188229a5edab5de17cae28ba1493422d9f
7
- data.tar.gz: c931cff17e29a01e531a20bc8196eb93d91179ca6cf4848c57ff6d8b1534e385aee75bf8ba9b10096d758e548a2fc941fefb97f8424203c873ee3f448d1657b6
6
+ metadata.gz: 9693803f8566fffbcc72b8b5c82ca71a02a86032ae6c27ba0c0168845243a20234d12726c10fbc28bc9d7af41bb1343af81302f7f2004e7a1d52cf8781b38a24
7
+ data.tar.gz: fb3cd3a8e4c0b528de2cf5c5de38d071dbbdeefa2d99efdf869d42796f7fb494d6281c6cfe4b72d2a8d3e0484b0658e447fc4fad7fa01bc99bd8d59ff5f9fefa
@@ -1,3 +1,3 @@
1
1
  module Pictureframe
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.8"
3
3
  end
data/lib/pictureframe.rb CHANGED
@@ -1,22 +1,38 @@
1
1
  require "pictureframe/version"
2
2
 
3
3
  module Pictureframe
4
- def self.frame(text, width = 5)
4
+ def self.frame(text, width = nil)
5
5
  inputLocation = 3
6
6
  output = []
7
7
  lefts = [".___", "| ._", "| | ", "| ._", "|___"]
8
8
  rights = ["___.", "_. |", " | |", "_. |", "___|"]
9
- totalLength = lefts[0].length + rights[0].length + text.length
10
- width = totalLength if totalLength > width
9
+ insideLines = [text]
10
+
11
+ if width
12
+ textSpace = width - (lefts[0].length * 2)
13
+ insideLines = textSpace < text.length ? breakText(text, textSpace) : [text]
14
+ else
15
+ totalLength = lefts[0].length + rights[0].length + text.length
16
+ width = totalLength if totalLength > width
17
+ end
18
+
11
19
  lefts.each_with_index do |row, i|
12
20
  filler = i == 2 ? " " : "_"
13
21
  output[i] = expandLine(lefts[i], rights[i], filler, width)
14
22
  end
15
- output = output.insert(inputLocation, expandLine("| | ", " | |", " ", width, text))
23
+
24
+ insideLines.reverse.each do |text|
25
+ output = output.insert(inputLocation, expandLine("| | ", " | |", " ", width, text))
26
+ end
27
+
16
28
  puts output.join("\n")
17
29
  return output
18
30
  end
19
31
 
32
+ def self.breakText(string, numChars)
33
+ string.scan(/#{'.{1,' + numChars.to_s}}/)
34
+ end
35
+
20
36
  def self.expandLine(left, right, filler, width, text = "")
21
37
  totalLength = left.length + right.length + text.length
22
38
  width = totalLength if totalLength > width
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pictureframe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Palmer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-01 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,8 +84,6 @@ files:
84
84
  - bin/setup
85
85
  - lib/pictureframe.rb
86
86
  - lib/pictureframe/version.rb
87
- - pictureframe-0.0.1.gem
88
- - pictureframe-0.0.2.gem
89
87
  - pictureframe.gemspec
90
88
  homepage: http://www.github.com/cdpalmer
91
89
  licenses:
Binary file
Binary file