Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit f5efda4

Browse files
committed
toString -> stringify
1 parent 2fdd36a commit f5efda4

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

src/GridNotation.coffee

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class GridNotation
430430
# Returns a String.
431431
stringifyCommands: (commands) =>
432432
string = ""
433-
string += @cmd.toString(command) for command in commands
433+
string += @cmd.stringify(command) for command in commands
434434
@pipeCleaner string
435435

436436
# Convert a grid's params to a guiden notation spec compliant string.
@@ -447,10 +447,10 @@ class GridNotation
447447
if params.firstOffset or params.width or params.lastOffset
448448
string += ", " if string.length > 0
449449

450-
string += @cmd.toString(params.firstOffset) if params.firstOffset
451-
string += "|#{ @cmd.toString(params.width) }|" if params.width
450+
string += @cmd.stringify(params.firstOffset) if params.firstOffset
451+
string += "|#{ @cmd.stringify(params.width) }|" if params.width
452452
string += "|" if params.firstOffset and params.lastOffset and !params.width
453-
string += @cmd.toString(params.lastOffset) if params.firstOffset
453+
string += @cmd.stringify(params.lastOffset) if params.firstOffset
454454

455455
if string then "( #{ @pipeCleaner(string) } )" else ''
456456

@@ -599,7 +599,7 @@ class Command
599599
# command - command to be converted to a string
600600
#
601601
# Returns an Integer.
602-
toString: (command = "") ->
602+
stringify: (command = "") ->
603603
return command if typeof command is "string"
604604
string = ""
605605

@@ -608,7 +608,7 @@ class Command
608608
else if command.isVariable
609609
string += command.id
610610
else if command.isExplicit
611-
string += @unit.toString(command.unit)
611+
string += @unit.stringify(command.unit)
612612
else if command.isWildcard
613613
string += "~"
614614
else
@@ -628,7 +628,7 @@ class Command
628628
# Returns a String.
629629
toSimpleString: (command = "") ->
630630
return command.replace(/\*.*/gi, "") if typeof command is "string"
631-
@toString(command).replace(/[\{\}]|\*.*/gi, "")
631+
@stringify(command).replace(/[\{\}]|\*.*/gi, "")
632632

633633
#
634634
# Unit is a utility for parsing and validating unit strings
@@ -716,9 +716,9 @@ class Unit
716716
# unit = string or object
717717
#
718718
# Returns a string
719-
toString: (unit = "") =>
719+
stringify: (unit = "") =>
720720
return null if unit == ""
721-
return @toString(@parse(unit)) if typeof unit == "string"
721+
return @stringify(@parse(unit)) if typeof unit == "string"
722722

723723
"#{ unit.value }#{ unit.type }"
724724

test/test-commands.coffee

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,38 +147,38 @@ describe 'Commands', ->
147147
describe 'Strings', ->
148148

149149
it 'should convert guide commands to strings', ->
150-
assert.equal "|", Command.toString
150+
assert.equal "|", Command.stringify
151151
errors: []
152152
isGuide: true
153153

154154
it 'should convert variable commands to strings', ->
155-
assert.equal "$", Command.toString
155+
assert.equal "$", Command.stringify
156156
errors: []
157157
isVariable: true
158158
isFill: false
159159
id: "$"
160160
multiplier: 1
161-
assert.equal "$foo*2", Command.toString
161+
assert.equal "$foo*2", Command.stringify
162162
errors: []
163163
isVariable: true
164164
isFill: false
165165
id: "$foo"
166166
multiplier: 2
167167

168168
it 'should convert wildcard commands to strings', ->
169-
assert.equal "~", Command.toString
169+
assert.equal "~", Command.stringify
170170
errors: []
171171
isWildcard: true
172172
isFill: false
173173
multiplier: 1
174-
assert.equal "~*2", Command.toString
174+
assert.equal "~*2", Command.stringify
175175
errors: []
176176
isWildcard: true
177177
isFill: false
178178
multiplier: 2
179179

180180
it 'should convert explicit commands to strings', ->
181-
assert.equal "10px*2", Command.toString
181+
assert.equal "10px*2", Command.stringify
182182
errors: []
183183
isExplicit: true
184184
isFill: false

test/test-units.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ describe 'Units', ->
9595
describe 'To string', ->
9696

9797
it 'should return null when given nothing', ->
98-
assert.strictEqual Unit.toString(), null
99-
assert.strictEqual Unit.toString(""), null
98+
assert.strictEqual Unit.stringify(), null
99+
assert.strictEqual Unit.stringify(""), null
100100

101101
it 'should return string when given a unit object', ->
102-
assert.equal Unit.toString(Unit.parse("1px")), "1px"
102+
assert.equal Unit.stringify(Unit.parse("1px")), "1px"
103103

104104
it 'should return string when given a string', ->
105-
assert.equal Unit.toString("1px"), "1px"
105+
assert.equal Unit.stringify("1px"), "1px"

0 commit comments

Comments
 (0)