monospace_text_formatter 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
data/Changelog
CHANGED
@@ -33,6 +33,11 @@ module MonospaceTextFormatter
|
|
33
33
|
@display_length
|
34
34
|
end
|
35
35
|
|
36
|
+
def non_display_length
|
37
|
+
slice_whole_remaining_string unless remaining_string.empty?
|
38
|
+
to_s.length - display_length
|
39
|
+
end
|
40
|
+
|
36
41
|
def concat(string_or_chunk)
|
37
42
|
|
38
43
|
if string_or_chunk.kind_of?(Chunk)
|
@@ -117,9 +122,9 @@ module MonospaceTextFormatter
|
|
117
122
|
end
|
118
123
|
|
119
124
|
def pop_atomic_chunk
|
120
|
-
|
121
|
-
@display_length -=
|
122
|
-
|
125
|
+
atomic_chunk = atomic_chunks.pop
|
126
|
+
@display_length -= atomic_chunk.display_length
|
127
|
+
atomic_chunk
|
123
128
|
end
|
124
129
|
|
125
130
|
def unshift_atomic_chunk(atomic_chunk)
|
@@ -128,15 +133,15 @@ module MonospaceTextFormatter
|
|
128
133
|
end
|
129
134
|
|
130
135
|
def shift_atomic_chunk
|
131
|
-
|
132
|
-
@display_length -=
|
133
|
-
|
136
|
+
atomic_chunk = atomic_chunks.shift
|
137
|
+
@display_length -= atomic_chunk.display_length
|
138
|
+
atomic_chunk
|
134
139
|
end
|
135
140
|
|
136
141
|
def delete_atomic_chunk_at(index)
|
137
|
-
|
138
|
-
@display_length -=
|
139
|
-
|
142
|
+
atomic_chunk = atomic_chunks.delete_at(index)
|
143
|
+
@display_length -= atomic_chunk.display_length
|
144
|
+
atomic_chunk
|
140
145
|
end
|
141
146
|
|
142
147
|
def retrieve_first_atomic_chunk
|
@@ -82,11 +82,11 @@ module MonospaceTextFormatter
|
|
82
82
|
else
|
83
83
|
case align
|
84
84
|
when :left
|
85
|
-
visible_chunk.to_s.ljust(@fixed_width, fill)
|
85
|
+
visible_chunk.to_s.ljust( @fixed_width + visible_chunk.non_display_length, fill)
|
86
86
|
when :center
|
87
|
-
visible_chunk.to_s.center(@fixed_width, fill)
|
87
|
+
visible_chunk.to_s.center(@fixed_width + visible_chunk.non_display_length, fill)
|
88
88
|
when :right
|
89
|
-
visible_chunk.to_s.rjust(@fixed_width, fill)
|
89
|
+
visible_chunk.to_s.rjust( @fixed_width + visible_chunk.non_display_length, fill)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monospace_text_formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-18 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &83233040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '2.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *83233040
|
25
25
|
description: Formats monospaced text into a line or visual box of defined 'width'
|
26
26
|
and 'height' boundaries (expressed in number of characters).
|
27
27
|
email: jacekmikrut.software@gmail.com
|