Massive rewrite to use DSL conventions

This commit is contained in:
Andy Meneely
2014-07-16 10:39:10 -04:00
parent c2f1a9673b
commit b001da7ba3
18 changed files with 163 additions and 179 deletions
+12
View File
@@ -0,0 +1,12 @@
module Squib
class Deck
#module API
def background(range: :all, color: '#000000')
range = rangeify(range)
range.each { |i| @cards[i].background(color) }
end
#end
end
end
+6
View File
@@ -0,0 +1,6 @@
module Squib
class Deck
def csv(file: 'deck.csv', header: true)
end
end
end
+8
View File
@@ -0,0 +1,8 @@
module Squib
class Deck
def png(range=:all, file: nil, x: 0, y: 0)
end
end
end
+16
View File
@@ -0,0 +1,16 @@
module Squib
class Deck
def save(range: :all, format: :png)
format = [format].flatten
save_png(range: range) if format.include? :png
save_pdf if format.include? :pdf
end
def save_png(range: :all)
range = rangeify(range)
range.each { |i| @cards[i].save_png(i) }
end
end
end
+13
View File
@@ -0,0 +1,13 @@
module Squib
class Deck
def rect(range: :all, x: 0, y: 0, width: 825, height: 1125, \
x_radius: 0, y_radius: 0)
range = rangeify(range)
range.each do |i|
@cards[i].draw_rectangle(x, y, width, height, x_radius, y_radius)
end
end
end
end
+19
View File
@@ -0,0 +1,19 @@
module Squib
class Deck
def font(type: 'Arial', size: 12, **options)
end
def set_font(type: 'Arial', size: 12, **options)
end
def text(range: :all, str: '', font: :use_set, x: 0, y: 0, **options)
range = rangeify(range)
str = [str] * @cards.size unless str.respond_to? :each
range.each do |i|
cards[i].text(str[i], font, x, y, options)
end
end
end
end