Skip to content

Commit 7b56ee5

Browse files
committed
Rigorously determine line width of Partials
Also begin to transition to using "height" and "width" for number of rows and number of columns respectively, but keep the old names for now.
1 parent 5ee22e3 commit 7b56ee5

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/remedy/partial.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,17 @@ def last
2727
lines.last
2828
end
2929

30-
def length
30+
def height
3131
lines.length
3232
end
33+
alias_method :length, :height
3334

3435
def width
35-
@width ||= lines.max{|line| line.length }.length
36+
lines.map{|line| line.length }.max
3637
end
3738

3839
def size
39-
Size.new length, width
40+
Size.new height, width
4041
end
4142

4243
def to_a

lib/remedy/size.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ def fits_into? size_to_fit_into
4545
def rows
4646
dimensions[0]
4747
end
48+
alias_method :height, :rows
4849

4950
def cols
5051
dimensions[1]
5152
end
52-
alias :columns :cols
53+
alias_method :columns, :cols
54+
alias_method :width, :cols
5355

5456
def [] index
5557
dimensions[index]

0 commit comments

Comments
 (0)