rrtf 1.2.0 → 1.3.0

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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +19 -0
  4. data/documentation/RRTF.html +5 -5
  5. data/documentation/RRTF/AnonymousStyle.html +2 -2
  6. data/documentation/RRTF/BorderFormatting.html +48 -48
  7. data/documentation/RRTF/BorderStyle.html +1 -1
  8. data/documentation/RRTF/CharacterFormatting.html +1 -1
  9. data/documentation/RRTF/CharacterStyle.html +1 -1
  10. data/documentation/RRTF/Colour.html +1 -1
  11. data/documentation/RRTF/ColourTable.html +1 -1
  12. data/documentation/RRTF/CommandNode.html +333 -93
  13. data/documentation/RRTF/ContainerNode.html +1 -1
  14. data/documentation/RRTF/Converters.html +1 -1
  15. data/documentation/RRTF/Converters/HTML.html +1 -1
  16. data/documentation/RRTF/Converters/HTML/Helpers.html +1 -1
  17. data/documentation/RRTF/Converters/HTML/Node.html +1 -1
  18. data/documentation/RRTF/Converters/HTML/NodeSet.html +1 -1
  19. data/documentation/RRTF/Document.html +2 -2
  20. data/documentation/RRTF/DocumentFormatting.html +48 -48
  21. data/documentation/RRTF/DocumentProperties.html +8 -3
  22. data/documentation/RRTF/Font.html +1 -1
  23. data/documentation/RRTF/FontTable.html +1 -1
  24. data/documentation/RRTF/FooterNode.html +2 -2
  25. data/documentation/RRTF/GeometryNode.html +2 -2
  26. data/documentation/RRTF/GeometryProperties.html +9 -9
  27. data/documentation/RRTF/HeaderNode.html +2 -2
  28. data/documentation/RRTF/ImageNode.html +64 -61
  29. data/documentation/RRTF/Information.html +1 -1
  30. data/documentation/RRTF/LinkNode.html +2 -2
  31. data/documentation/RRTF/ListLevel.html +1 -1
  32. data/documentation/RRTF/ListLevelNode.html +2 -2
  33. data/documentation/RRTF/ListMarker.html +1 -1
  34. data/documentation/RRTF/ListNode.html +2 -2
  35. data/documentation/RRTF/ListTable.html +1 -1
  36. data/documentation/RRTF/ListTemplate.html +1 -1
  37. data/documentation/RRTF/ListTextNode.html +2 -2
  38. data/documentation/RRTF/Node.html +1 -1
  39. data/documentation/RRTF/Page.html +1 -1
  40. data/documentation/RRTF/Page/Margin.html +1 -1
  41. data/documentation/RRTF/Page/Size.html +1 -1
  42. data/documentation/RRTF/PageFormatting.html +184 -195
  43. data/documentation/RRTF/ParagraphFormatting.html +75 -48
  44. data/documentation/RRTF/ParagraphNode.html +2 -2
  45. data/documentation/RRTF/ParagraphStyle.html +1 -1
  46. data/documentation/RRTF/PositionFormatting.html +48 -48
  47. data/documentation/RRTF/PositionStyle.html +1 -1
  48. data/documentation/RRTF/Properties.html +1 -1
  49. data/documentation/RRTF/RTFError.html +1 -1
  50. data/documentation/RRTF/SectionFormatting.html +750 -0
  51. data/documentation/RRTF/SectionNode.html +383 -0
  52. data/documentation/RRTF/SectionStyle.html +830 -0
  53. data/documentation/RRTF/ShadingFormatting.html +48 -48
  54. data/documentation/RRTF/ShadingStyle.html +1 -1
  55. data/documentation/RRTF/Style.html +2 -2
  56. data/documentation/RRTF/Stylesheet.html +1 -1
  57. data/documentation/RRTF/TabStyle.html +698 -0
  58. data/documentation/RRTF/TableCellNode.html +2 -2
  59. data/documentation/RRTF/TableNode.html +1 -1
  60. data/documentation/RRTF/TableRowNode.html +1 -1
  61. data/documentation/RRTF/TextNode.html +1 -1
  62. data/documentation/RRTF/Utilities.html +1 -1
  63. data/documentation/_index.html +33 -5
  64. data/documentation/class_list.html +1 -1
  65. data/documentation/file.README.html +32 -1
  66. data/documentation/index.html +32 -1
  67. data/documentation/method_list.html +499 -355
  68. data/documentation/top-level-namespace.html +1 -1
  69. data/examples/11.rtf +9 -8
  70. data/examples/12.rtf +19 -0
  71. data/examples/12_tabs.rb +21 -0
  72. data/lib/rrtf/formatting.rb +27 -0
  73. data/lib/rrtf/node/command_node.rb +8 -0
  74. data/lib/rrtf/style.rb +1 -0
  75. data/lib/rrtf/style/tab_style.rb +55 -0
  76. data/lib/rrtf/version.rb +1 -1
  77. metadata +8 -1
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Mon Jul 31 21:48:57 2017 by
103
+ Generated on Wed Aug 2 23:05:14 2017 by
104
104
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.9 (ruby-2.3.3).
106
106
  </div>
@@ -3,16 +3,17 @@
3
3
  {\f0\fswiss Helvetica;}
4
4
  }
5
5
  {\info
6
- {\createim\yr2017\mo8\dy2\hr9\min41}
6
+ {\createim\yr2017\mo8\dy2\hr22\min31}
7
7
  }
8
8
 
9
9
  \hyphauto1\paperw12247\paperh15819\margl1440\margr1440\margt1440\margb1440
10
- {\pard
11
- Redshirt Pocket Guide
12
- \par}
13
- \sect\sectd\cols2 \paperw12247\paperh15819\margl1440\margr1440\margt1440\margb1440
14
-
15
- {\pard
16
- Section Text
10
+ {\pard\ql\ltrpar\rqr\tldot\tx2880
11
+ Engineers
12
+ {\tab}
13
+ 10
14
+ {\line}
15
+ Redshirts
16
+ {\tab}
17
+ 100
17
18
  \par}
18
19
  }
@@ -0,0 +1,19 @@
1
+ {\rtf1\ansi\deff0\deflang1033\plain\fs24\fet1
2
+ {\fonttbl
3
+ {\f0\fswiss Helvetica;}
4
+ }
5
+ {\info
6
+ {\createim\yr2017\mo8\dy2\hr22\min32}
7
+ }
8
+
9
+ \hyphauto1\paperw12247\paperh15819\margl1440\margr1440\margt1440\margb1440
10
+ {\pard\ql\ltrpar\rqr\tldot\tx2880
11
+ Engineers
12
+ {\tab}
13
+ 10
14
+ {\line}
15
+ Redshirts
16
+ {\tab}
17
+ 100
18
+ \par}
19
+ }
@@ -0,0 +1,21 @@
1
+ require 'rrtf'
2
+
3
+ DIR = File.dirname(__FILE__)
4
+
5
+ rtf = RRTF::Document.new
6
+
7
+ rtf.paragraph("tabs" => {
8
+ "leader" => "DOT",
9
+ "type" => "FLUSH_RIGHT",
10
+ "position" => "2in"
11
+ }) do |p|
12
+ p << "Engineers"
13
+ p.tab
14
+ p << "10"
15
+ p.line_break
16
+ p << "Redshirts"
17
+ p.tab
18
+ p << "100"
19
+ end
20
+
21
+ File.open(DIR+'/12.rtf', 'w') { |file| file.write(rtf.to_rtf) }
@@ -332,6 +332,33 @@ module RRTF::ParagraphFormatting
332
332
  end # case
333
333
  end,
334
334
  "to_rtf" => lambda{ |value, document| value.rtf_formatting(document) unless value.nil? }
335
+ },
336
+ "tabs" => {
337
+ "default" => nil,
338
+ "from_user" => lambda do |value|
339
+ case value
340
+ when Array
341
+ value.collect do |t|
342
+ case t
343
+ when Hash
344
+ RRTF::TabStyle.new(t)
345
+ when RRTF::TabStyle
346
+ t
347
+ else
348
+ RRTF::RTFError.fire("Invalid tab '#{t}'.")
349
+ end # case
350
+ end # collect
351
+ when Hash
352
+ [RRTF::TabStyle.new(value)]
353
+ when RRTF::TabStyle
354
+ [value]
355
+ else
356
+ RRTF::RTFError.fire("Invalid border '#{value}'.")
357
+ end # case
358
+ end,
359
+ "to_rtf" => lambda do |value, document|
360
+ value.collect{ |tab| tab.rtf_formatting }.join(' ') unless value.nil?
361
+ end
335
362
  }
336
363
  }.freeze
337
364
 
@@ -172,6 +172,14 @@ module RRTF
172
172
  nil
173
173
  end
174
174
 
175
+ # This method provides a short cut means of creating a tab command
176
+ # node. This command node does not take a block and may possess no other
177
+ # content.
178
+ def tab
179
+ self.store(CommandNode.new(self, '\tab', nil, false))
180
+ nil
181
+ end
182
+
175
183
  # This method inserts a footnote at the current position in a node.
176
184
  #
177
185
  # ==== Parameters
@@ -2,6 +2,7 @@ require 'rrtf/style/anonymous_style'
2
2
  require 'rrtf/style/border_style'
3
3
  require 'rrtf/style/position_style'
4
4
  require 'rrtf/style/shading_style'
5
+ require 'rrtf/style/tab_style'
5
6
  require 'rrtf/style/style'
6
7
  require 'rrtf/style/paragraph_style'
7
8
  require 'rrtf/style/character_style'
@@ -0,0 +1,55 @@
1
+ require 'stringio'
2
+
3
+ module RRTF
4
+ # Represents a set of formatting that can be applied to paragraph and table
5
+ # borders
6
+ class TabStyle < AnonymousStyle
7
+
8
+ TYPE_DICTIONARY = {
9
+ "FLUSH_RIGHT" => 'rqr',
10
+ "CENTERED" => 'tqc',
11
+ "DECIMAL" => 'tqdec'
12
+ }.freeze
13
+
14
+ LEADER_DICTIONARY = {
15
+ "DOT" => 'tldot',
16
+ "MIDDLE_DOT" => 'tlmdot',
17
+ "HYPHEN" => 'tlhyph',
18
+ "UNDERLINE" => 'tlul',
19
+ "THICK_LINE" => 'tlth',
20
+ "EQUAL" => 'tleq'
21
+ }.freeze
22
+
23
+ attr_accessor :type, :leader, :position
24
+
25
+ # This is the constructor for the BorderStyle class.
26
+ #
27
+ # @param [Hash] options the tab style options.
28
+ # @option options (see AnonymousStyle#initialize)
29
+ # @option options [String] "type" (nil) the tab type ("FLUSH_RIGHT", "CENTERED", or "DECIMAL").
30
+ # @option options [String] "leader" (nil) the leader type ("DOT", "MIDDLE_DOT","HYPHEN", "UNDERLINE", "THICK_LINE", or "EQUAL").
31
+ # @option options [String, Integer] "position" (720) the position of the tab stop from the left margin in twips (can be a string, see {Utilities.value2twips}).
32
+ def initialize(options = {})
33
+ super(options)
34
+ @type = TYPE_DICTIONARY[options.delete("type")]
35
+ @leader = LEADER_DICTIONARY[options.delete("leader")]
36
+ @position = Utilities.value2twips(options.delete("position")) || 720
37
+ end
38
+
39
+ # This method generates a string containing the prefix associated with the
40
+ # style object. Equivalent to {#rtf_formatting} for the TabStyle class.
41
+ def prefix(document)
42
+ rtf_formatting
43
+ end
44
+
45
+ def rtf_formatting
46
+ rtf = StringIO.new
47
+
48
+ rtf << "\\#{@type}" unless @type.nil?
49
+ rtf << "\\#{@leader}" unless @leader.nil?
50
+ rtf << "\\tx#{@position}"
51
+
52
+ rtf.string
53
+ end
54
+ end # class TabStyle
55
+ end # module RRTF
@@ -1,3 +1,3 @@
1
1
  module RRTF
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrtf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wesley Hileman
@@ -188,10 +188,14 @@ files:
188
188
  - documentation/RRTF/PositionStyle.html
189
189
  - documentation/RRTF/Properties.html
190
190
  - documentation/RRTF/RTFError.html
191
+ - documentation/RRTF/SectionFormatting.html
192
+ - documentation/RRTF/SectionNode.html
193
+ - documentation/RRTF/SectionStyle.html
191
194
  - documentation/RRTF/ShadingFormatting.html
192
195
  - documentation/RRTF/ShadingStyle.html
193
196
  - documentation/RRTF/Style.html
194
197
  - documentation/RRTF/Stylesheet.html
198
+ - documentation/RRTF/TabStyle.html
195
199
  - documentation/RRTF/TableCellNode.html
196
200
  - documentation/RRTF/TableNode.html
197
201
  - documentation/RRTF/TableRowNode.html
@@ -233,6 +237,8 @@ files:
233
237
  - examples/10_stylesheet.rb
234
238
  - examples/11.rtf
235
239
  - examples/11_sections.rb
240
+ - examples/12.rtf
241
+ - examples/12_tabs.rb
236
242
  - examples/resources/images/redshirt.png
237
243
  - examples/resources/images/redshirts.jpg
238
244
  - examples/resources/json/redshirt_styles.json
@@ -280,6 +286,7 @@ files:
280
286
  - lib/rrtf/style/section_style.rb
281
287
  - lib/rrtf/style/shading_style.rb
282
288
  - lib/rrtf/style/style.rb
289
+ - lib/rrtf/style/tab_style.rb
283
290
  - lib/rrtf/stylesheet.rb
284
291
  - lib/rrtf/utilities.rb
285
292
  - lib/rrtf/version.rb