From 0224856c9a526bec658e563c7bc2514cc9aaeda6 Mon Sep 17 00:00:00 2001 From: Andy Meneely Date: Wed, 9 Jul 2014 22:43:28 -0400 Subject: [PATCH] Putting this in only to take it out soon --- lib/squib/commands/command.rb | 17 +++++++++++++++++ lib/squib/commands/font.rb | 17 +++++++++++++++++ lib/squib/commands/set_font.rb | 17 +++++++++++++++++ lib/squib/queue.rb | 11 +++++++++++ lib/squib/render/context.rb | 11 +++++++++++ lib/squib/visitors/base_visitor.rb | 12 ++++++++++++ lib/squib/visitors/verify_visitor.rb | 15 +++++++++++++++ 7 files changed, 100 insertions(+) create mode 100644 lib/squib/commands/command.rb create mode 100644 lib/squib/commands/font.rb create mode 100644 lib/squib/commands/set_font.rb create mode 100644 lib/squib/queue.rb create mode 100644 lib/squib/render/context.rb create mode 100644 lib/squib/visitors/base_visitor.rb create mode 100644 lib/squib/visitors/verify_visitor.rb diff --git a/lib/squib/commands/command.rb b/lib/squib/commands/command.rb new file mode 100644 index 0000000..8d3fef2 --- /dev/null +++ b/lib/squib/commands/command.rb @@ -0,0 +1,17 @@ +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 \ No newline at end of file diff --git a/lib/squib/commands/font.rb b/lib/squib/commands/font.rb new file mode 100644 index 0000000..31744cf --- /dev/null +++ b/lib/squib/commands/font.rb @@ -0,0 +1,17 @@ +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 \ No newline at end of file diff --git a/lib/squib/commands/set_font.rb b/lib/squib/commands/set_font.rb new file mode 100644 index 0000000..257dbc9 --- /dev/null +++ b/lib/squib/commands/set_font.rb @@ -0,0 +1,17 @@ +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 \ No newline at end of file diff --git a/lib/squib/queue.rb b/lib/squib/queue.rb new file mode 100644 index 0000000..611ec0e --- /dev/null +++ b/lib/squib/queue.rb @@ -0,0 +1,11 @@ +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 \ No newline at end of file diff --git a/lib/squib/render/context.rb b/lib/squib/render/context.rb new file mode 100644 index 0000000..23d03f0 --- /dev/null +++ b/lib/squib/render/context.rb @@ -0,0 +1,11 @@ +module Squib + module Render + + class RenderContext + attr_accessor :font #current font we're using + attr_accessor :cur #index of the current card rendering + attr_accessor :cards #total number of cards we're iterating over + end + + end +end \ No newline at end of file diff --git a/lib/squib/visitors/base_visitor.rb b/lib/squib/visitors/base_visitor.rb new file mode 100644 index 0000000..458d1dc --- /dev/null +++ b/lib/squib/visitors/base_visitor.rb @@ -0,0 +1,12 @@ +module Squib + module Visitors + + class BaseVisitor + def visit subject + method_name = "visit_#{subject.class}".intern + send(method_name, subject) + end + end + + end +end \ No newline at end of file diff --git a/lib/squib/visitors/verify_visitor.rb b/lib/squib/visitors/verify_visitor.rb new file mode 100644 index 0000000..033db3b --- /dev/null +++ b/lib/squib/visitors/verify_visitor.rb @@ -0,0 +1,15 @@ +module Squib + module Visitors + + class VerifyVistior < BaseVisitor + def visit_Font + puts "Verify Font!!" + end + + def visit_SetFont + puts "Verify SetFont!!" + end + end + + end +end \ No newline at end of file