UNPKG

932 BJavaScriptView Raw
1// Generated by CoffeeScript 1.6.2
2(function() {
3 var Field, Segment, _;
4
5 _ = require('underscore');
6
7 Field = require('./Field');
8
9 Segment = (function() {
10 function Segment(fields, control) {
11 this.control = control;
12 this.name = _.first(_.flatten(fields));
13 this.fields = _.reduce(fields, function(memo, field) {
14 memo.push(new Field(field, this.control));
15 return memo;
16 }, [], this);
17 }
18
19 Segment.prototype.getValue = function(index) {
20 var _ref;
21
22 return ((_ref = this.fields[index]) != null ? _ref.val() : void 0) || '';
23 };
24
25 Segment.prototype.getPart = function(index) {
26 return this.fields[index];
27 };
28
29 Segment.prototype.toString = function() {
30 return _.map(this.fields, function(field) {
31 return field.toString();
32 }).join(this.control.fields);
33 };
34
35 return Segment;
36
37 })();
38
39 module.exports = Segment;
40
41}).call(this);