marginalise 0.1
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.
- checksums.yaml +7 -0
- data/lib/marginalise.rb +17 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4bbd4baa882deb6af7ec47f48c0664bd568128ffef466c65895e0ce9b65946cf
|
4
|
+
data.tar.gz: d304e7ca42cc7bd42894646b7ede0a7a39d87d8e080a63aff1088179a791391d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c22b71051c91ea8eb427e786ef6fb2ac5c4cf1411a88531ee9795802df59ca15f7684e7dd68fbcaf328980d408c75714a0fdc469557bb8aefb2ea5a8869c333
|
7
|
+
data.tar.gz: d5d961ad9856196bdbd0a34d788cd96ad5ceea767efbf9aa02015dcd245ef2bd82d0e72da4261d4bfb21e36c27303f4ca74d7aa1ee61fe764ee50b330d8009d7
|
data/lib/marginalise.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class String
|
2
|
+
def marginalise(m)
|
3
|
+
lines = [""]
|
4
|
+
self.split(' ').each do |word|
|
5
|
+
if (lines.last.size + word.size + 1) < m
|
6
|
+
if lines.last == ""
|
7
|
+
lines[lines.size-1] = word
|
8
|
+
else
|
9
|
+
lines[lines.size-1] = lines.last+" "+word
|
10
|
+
end
|
11
|
+
else
|
12
|
+
lines << word
|
13
|
+
end
|
14
|
+
end
|
15
|
+
return lines.join "\n"
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: marginalise
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan McCoskrie
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-31 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Reformats strings to a given margin
|
14
|
+
email: work@ryanmccoskrie.me
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/marginalise.rb
|
20
|
+
homepage: http://gitlab.com/RyanMcCoskrie/Marginalise
|
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.7.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Marginalise
|
44
|
+
test_files: []
|