Skip to content

Commit 508d35a

Browse files
committed
refactor(ngPluralize): minor tweaks and code style
1 parent 7f921d3 commit 508d35a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/directive/ng_pluralize.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ class NgPluralizeDirective {
9393
final Scope scope;
9494
final Interpolate interpolate;
9595
int offset;
96-
var discreteRules = <String, String>{};
97-
var categoryRules = <Symbol, String>{};
96+
final discreteRules = <String, String>{};
97+
final categoryRules = <Symbol, String>{};
9898

9999
static final RegExp IS_WHEN = new RegExp(r'^when-(minus-)?.');
100100
static const Map<String, Symbol> SYMBOLS = const {
@@ -108,32 +108,34 @@ class NgPluralizeDirective {
108108

109109
NgPluralizeDirective(this.scope, this.element, this.interpolate,
110110
NodeAttrs attributes) {
111-
var whens = attributes['when'] == null
111+
final whens = attributes['when'] == null
112112
? <String, String>{}
113113
: scope.eval(attributes['when']);
114114
offset = attributes['offset'] == null ? 0 : int.parse(attributes['offset']);
115115

116116
element.attributes.keys.where((k) => IS_WHEN.hasMatch(k)).forEach((k) {
117-
var ruleName = k.replaceFirst('when-', '').replaceFirst('minus-', '-');
117+
var ruleName = k
118+
.replace(new RegExp('^when-'), '')
119+
.replace(new RegExp('^minus-'), '-');
118120
whens[ruleName] = element.attributes[k];
119121
});
120122

121123
if (whens['other'] == null) {
122124
throw "ngPluralize error! The 'other' plural category must always be "
123-
"specified";
125+
"specified";
124126
}
125127

126128
whens.forEach((k, v) {
127129
Symbol symbol = SYMBOLS[k];
128130
if (symbol != null) {
129-
this.categoryRules[symbol] = v;
131+
categoryRules[symbol] = v;
130132
} else {
131-
this.discreteRules[k] = v;
133+
discreteRules[k] = v;
132134
}
133135
});
134136
}
135137

136-
set count(value) {
138+
void set count(value) {
137139
if (value is! num) {
138140
try {
139141
value = int.parse(value);

0 commit comments

Comments
 (0)