Browse Source

Still messing around

dev
Andy Meneely 12 years ago
parent
commit
09a668a3a9
  1. 1
      .gitignore
  2. 6
      Rakefile
  3. 8
      lib/squib.rb
  4. 9
      lib/squib/card.rb
  5. 17
      lib/squib/commands/command.rb
  6. 17
      lib/squib/commands/font.rb
  7. 17
      lib/squib/commands/set_font.rb
  8. 7
      lib/squib/commands/text_cmd.rb
  9. 0
      lib/squib/context.rb
  10. 18
      lib/squib/deck.rb
  11. 11
      lib/squib/queue.rb
  12. 12
      lib/squib/visitors/base_visitor.rb
  13. 15
      lib/squib/visitors/verify_visitor.rb
  14. 12
      spec/deck_spec.rb
  15. 1
      squib.gemspec

1
.gitignore vendored

@ -1,3 +1,4 @@
.DS_Store
*.gem
*.rbc
.bundle

6
Rakefile

@ -1,2 +1,6 @@
require "bundler/gem_tasks"
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec

8
lib/squib.rb

@ -1,6 +1,4 @@
require 'squib/commands/command'
require 'squib/commands/font'
require 'squib/commands/set_font'
require 'squib/commands/text_cmd'
require 'squib/queue'
@ -9,11 +7,11 @@ require 'squib/queue'
##################
def deck(width:, height:, cards: 1)
Deck.new(width, height, cards)
end
def font(type: , size: 12, **options)
Squib::queue_command Squib::Commands::Font.new(type,size,options)
Font.new()
end
def set_font(type: 'Arial', size: 12, **options)

9
lib/squib/card.rb

@ -0,0 +1,9 @@
module Squib
class Card
def initialize(width: 825, height: 1125)
@width=width, @height=height
end
end
end

17
lib/squib/commands/command.rb

@ -1,17 +0,0 @@
module Squib
module Commands
module Visitable
def accept visitor
visitor.visit self
end
end
class Command
def accept visitor
raise NotImpelementedError.new
end
end
end
end

17
lib/squib/commands/font.rb

@ -1,17 +0,0 @@
module Squib
module Commands
class Font < Command
include Visitable
attr_accessor :type, :size
def initialize(type,size, options)
@type = type
@size = size
#no other options yet
end
end
end
end

17
lib/squib/commands/set_font.rb

@ -1,17 +0,0 @@
module Squib
module Commands
class SetFont < Command
include Visitable
attr_accessor :type, :size, :options
def initialize(type, size, options)
@type = type
@size = size
#no options yet
end
end
end
end

7
lib/squib/commands/text_cmd.rb

@ -0,0 +1,7 @@
module Squib
class TextCmd
end
end

0
lib/squib/render/context.rb → lib/squib/context.rb

18
lib/squib/deck.rb

@ -0,0 +1,18 @@
require 'squib/card'
module Squib
class Deck
attr_reader :width, :height, :cards
def initialize(width: 825, height: 1125, cards: 1)
@width=width; @height=height; @cards=cards
@deck = Array.new(cards)
(1..cards).each{ @deck << Squib::Card.new(width: width, height: height) }
end
end
end

11
lib/squib/queue.rb

@ -1,11 +0,0 @@
module Squib
#Global queue of commands
CMDS = []
def queue_command(cmd)
unless cmd.instance_of? Squib::Commands::Command
raise ArgumentError, "Only RockDeck::Commands allowed here"
end
CMDS << cmd
end
end

12
lib/squib/visitors/base_visitor.rb

@ -1,12 +0,0 @@
module Squib
module Visitors
class BaseVisitor
def visit subject
method_name = "visit_#{subject.class}".intern
send(method_name, subject)
end
end
end
end

15
lib/squib/visitors/verify_visitor.rb

@ -1,15 +0,0 @@
module Squib
module Visitors
class VerifyVistior < BaseVisitor
def visit_Font
puts "Verify Font!!"
end
def visit_SetFont
puts "Verify SetFont!!"
end
end
end
end

12
spec/deck_spec.rb

@ -0,0 +1,12 @@
require 'squib/deck'
include Squib
describe Deck.new do
it "initializes with default parameters" do
d = Deck.new
expect(d.width).to eq(825)
expect(d.height).to eq(1125)
expect(d.cards).to eq(1)
end
end

1
squib.gemspec

@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
end

Loading…
Cancel
Save