Skip to content

Commit

Permalink
Conditional Top Boundary Sides
Browse files Browse the repository at this point in the history
  • Loading branch information
liamrosenfeld committed Apr 20, 2019
1 parent 783eb5f commit f20f9fc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions Sources/AnimalFarm/Bubble/Bubble.swift
Expand Up @@ -12,4 +12,5 @@ public struct Bubble {
var left: Character
var right: Character
public var line: String
var topSides: Bool
}
9 changes: 8 additions & 1 deletion Sources/AnimalFarm/Bubble/BubbleBuilder.swift
Expand Up @@ -12,6 +12,7 @@ internal class BubbleBuilder {
let btmChar: Character
let leftChar: Character
let rightChar: Character
let topSides: Bool

// Bubble Dimensions
let maxSignWidth = 32
Expand Down Expand Up @@ -47,7 +48,12 @@ internal class BubbleBuilder {

func buildSignBoundary(length: Int, char: Character) -> String {
let dashes = String(repeating: char, count: length)
return "\(leftChar)\(dashes)\(rightChar)"
if topSides {
return "\(leftChar)\(dashes)\(rightChar)"
} else {
return " \(dashes) "
}

}

// Line Splitting
Expand Down Expand Up @@ -100,5 +106,6 @@ internal class BubbleBuilder {
self.btmChar = style.btm
self.leftChar = style.left
self.rightChar = style.right
self.topSides = style.topSides
}
}
12 changes: 8 additions & 4 deletions Sources/AnimalFarm/Bubble/Bubbles.swift
Expand Up @@ -12,21 +12,24 @@ public let bubbles = [
btm: "~",
left: "(",
right: ")",
line: "0"
line: "0",
topSides: false
),
"yell": Bubble(
top: "",
btm: "",
left: "<",
right: ">",
line: "X"
line: "X",
topSides: false
),
"sign": Bubble(
top: "-",
btm: "-",
left: "|",
right: "|",
line: ""
line: "",
topSides: true
),
]

Expand All @@ -35,5 +38,6 @@ public let say = Bubble(
btm: "-",
left: "|",
right: "|",
line: "\\"
line: "\\",
topSides: true
)

0 comments on commit f20f9fc

Please sign in to comment.