Skip to content

Commit f1c0650

Browse files
author
Robert Jackson
committed
More fixes to the README.
1 parent d7ee71b commit f1c0650

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,28 +151,37 @@ Using the simple transaction set and segments defined above, here are a few ways
151151
the fields.
152152

153153
To create a transaction set simple choose the set you want and call new on it's Base class.
154+
154155
```ruby
155156
ts = Hippo::TransactionSets::Test::Base.new
156157
```
158+
157159
The segments can be accessed directly from the created transaction set using the segment
158160
identifier.
161+
159162
```ruby
160163
ts.TCS
161164
```
165+
162166
Since the TSS segment can be repeated we must call #build to generate a new
163167
instance for each repeat. (You will be returned the first instance each time if you
164168
do not call #build.)
169+
165170
```ruby
166171
ts.TSS.build
167172
```
173+
168174
The code above produces the following string output (notice how the values from
169175
:defaults are prefilled, and the output is automatically sorted based on the order
170176
that the segments were declared):
177+
171178
```ruby
172179
# ts.to_s => 'TSS*Blah~TCS***Preset Field 7~'
173180
```
181+
174182
To set field values on a given segment you can access it either by calling the field directly
175183
on the segment or by passing a block to the segment.
184+
176185
```ruby
177186
# this is one way to populate the fields
178187
ts.TCS.Field1 = 'Foo'
@@ -205,11 +214,14 @@ TSS_02 instead.
205214

206215
# ts.to_s => 'TSS*Blah*Bar~TCS*Foo**Preset Field 7~TSS*Last Segment*Baz~'
207216
```
217+
208218
The same technique can be used to reference fields within a segment that have the same name.
219+
209220
```ruby
210221
ts.TSS.CommonName = 'Value1'
211222
ts.TSS.CommonName_02 = 'Value2'
212223

213224
# ts.to_s => 'TSS*Blah*Bar***Value1*Value2~TCS*Foo**Preset Field 7~TSS*Last Segment*Baz~'
214225
```
226+
215227
For more example please review the test suite.

0 commit comments

Comments
 (0)