Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

moving around diles

git-svn-id: svn+ssh://rubyforge.org/var/svn/betabrite/trunk@21 32089d7b-f314-0410-b504-a527b3b390a0
  • Loading branch information...
commit 46247fe668dba213a7bb8f54515d8ebad4a8e6bf 1 parent 24cc040
aaronp authored
90 lib/betabrite.rb
... ... @@ -1,88 +1,6 @@
1   -require 'string'
2   -require 'files/textfile'
3   -require 'files/stringfile'
4   -require 'files/dotsfile'
5   -require 'memory/memory'
  1 +require 'betabrite/string'
  2 +require 'betabrite/files'
  3 +require 'betabrite/base'
6 4 require 'betabrite/usb'
  5 +require 'betabrite/memory'
7 6
8   -# = Synopsis
9   -# This class assembles all packets (different files) and yields the data
10   -# that needs to be written back to the caller of the BetaBrite#write method.
11   -class BetaBrite
12   - HEADER = [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ]
13   - STX = 0x02.chr
14   - ETX = 0x03.chr
15   - EOT = 0x04.chr
16   - ESC = 0x1b.chr
17   - DLE = 0x10.chr
18   - STRING = 0x14.chr
19   - CR = 0x0d.chr
20   - MEMORY_CODE = "E$"
21   -
22   - # Beta Brite sign
23   - SIGN_TYPE = 0x5a.chr
24   -
25   - VERSION = '0.1.0'
26   -
27   - attr_accessor :sleep_time
28   - attr_reader :string_files, :text_files, :dots_files, :memory
29   -
30   - def initialize
31   - # Default address is "00" which means broadcast to all signs
32   - @sign_address = [ 0x30, 0x30 ]
33   - @string_files = []
34   - @text_files = []
35   - @dots_files = []
36   - @memory = []
37   -
38   - # This shouldn't change except for unit testing
39   - @sleep_time = 0
40   - yield self if block_given?
41   - end
42   -
43   - def textfile(label = 'A', &block)
44   - @text_files << BetaBrite::TextFile.new(label, &block)
45   - end
46   -
47   - def stringfile(label, message = nil, &block)
48   - @string_files << BetaBrite::StringFile.new(label, message, &block)
49   - end
50   -
51   - def dotsfile(label, rows = nil, columns = nil, picture = nil, &block)
52   - @dots_files << BetaBrite::DotsFile.new(label, rows, columns, picture,&block)
53   - end
54   -
55   - def allocate(&block)
56   - @memory.push(*(BetaBrite::Memory::Factory.find(&block)))
57   - end
58   -
59   - def clear_memory!
60   - @memory << BetaBrite::Memory::Clear.new
61   - end
62   -
63   - # Get the message to be sent to the sign
64   - def message
65   - header +
66   - @text_files.each { |tf| tf.to_s }.join('') +
67   - @string_files.each { |tf| tf.to_s }.join('') +
68   - @dots_files.each { |tf| tf.to_s }.join('') +
69   - tail
70   - end
71   -
72   - def memory_message
73   - "#{header}#{STX}#{MEMORY_CODE}#{@memory.map { |packet| packet.to_s }.join('')}#{tail}"
74   - end
75   -
76   - private
77   -
78   - def header
79   - header_str = HEADER.collect { |a| a.chr }.join
80   - header_str << SIGN_TYPE << @sign_address.collect { |a| a.chr }.join
81   - end
82   - alias :inspect :header
83   - public :inspect
84   -
85   - def tail
86   - EOT
87   - end
88   -end
85 lib/betabrite/base.rb
... ... @@ -0,0 +1,85 @@
  1 +module BetaBrite
  2 + VERSION = '1.0.0'
  3 +
  4 + class Base
  5 + include BetaBrite::Files
  6 +
  7 + # = Synopsis
  8 + # This class assembles all packets (different files) and yields the data
  9 + # that needs to be written back to the caller of the BetaBrite#write method.
  10 + HEADER = [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ]
  11 + STX = 0x02.chr
  12 + ETX = 0x03.chr
  13 + EOT = 0x04.chr
  14 + ESC = 0x1b.chr
  15 + DLE = 0x10.chr
  16 + STRING = 0x14.chr
  17 + CR = 0x0d.chr
  18 + MEMORY_CODE = "E$"
  19 +
  20 + # Beta Brite sign
  21 + SIGN_TYPE = 0x5a.chr
  22 +
  23 + attr_accessor :sleep_time
  24 + attr_reader :string_files, :text_files, :dots_files, :memory
  25 +
  26 + def initialize
  27 + # Default address is "00" which means broadcast to all signs
  28 + @sign_address = [ 0x30, 0x30 ]
  29 + @string_files = []
  30 + @text_files = []
  31 + @dots_files = []
  32 + @memory = []
  33 +
  34 + # This shouldn't change except for unit testing
  35 + @sleep_time = 0
  36 + yield self if block_given?
  37 + end
  38 +
  39 + def textfile(label = 'A', &block)
  40 + @text_files << Text.new(label, &block)
  41 + end
  42 +
  43 + def stringfile(label, message = nil, &block)
  44 + @string_files << String.new(label, message, &block)
  45 + end
  46 +
  47 + def dotsfile(label, rows = nil, columns = nil, picture = nil, &block)
  48 + @dots_files << Dots.new(label, rows, columns, picture,&block)
  49 + end
  50 +
  51 + def allocate(&block)
  52 + @memory.push(*(BetaBrite::Memory::Factory.find(&block)))
  53 + end
  54 +
  55 + def clear_memory!
  56 + @memory << BetaBrite::Memory::Clear.new
  57 + end
  58 +
  59 + # Get the message to be sent to the sign
  60 + def message
  61 + header +
  62 + @text_files.each { |tf| tf.to_s }.join('') +
  63 + @string_files.each { |tf| tf.to_s }.join('') +
  64 + @dots_files.each { |tf| tf.to_s }.join('') +
  65 + tail
  66 + end
  67 +
  68 + def memory_message
  69 + "#{header}#{STX}#{MEMORY_CODE}#{@memory.map { |packet| packet.to_s }.join('')}#{tail}"
  70 + end
  71 +
  72 + private
  73 +
  74 + def header
  75 + header_str = HEADER.collect { |a| a.chr }.join
  76 + header_str << SIGN_TYPE << @sign_address.collect { |a| a.chr }.join
  77 + end
  78 + alias :inspect :header
  79 + public :inspect
  80 +
  81 + def tail
  82 + EOT
  83 + end
  84 + end
  85 +end
3  lib/betabrite/files.rb
... ... @@ -0,0 +1,3 @@
  1 +require 'betabrite/files/stringfile'
  2 +require 'betabrite/files/textfile'
  3 +require 'betabrite/files/dotsfile'
24 lib/betabrite/files/dotsfile.rb
... ... @@ -0,0 +1,24 @@
  1 +module BetaBrite
  2 + module Files
  3 + class Dots
  4 + COMMAND_CODE = 0x49.chr
  5 +
  6 + attr_accessor :label, :rows, :columns, :picture
  7 +
  8 + def initialize(label, rows, columns, picture, &block)
  9 + @label = label
  10 + @rows = rows
  11 + @columns = columns
  12 + @picture = picture
  13 + instance_eval(&block) if block
  14 + end
  15 +
  16 + def to_s
  17 + string = "#{BetaBrite::Base::STX}#{COMMAND_CODE}#{@label.to_s}" +
  18 + "#{sprintf('%02x', @rows)}#{sprintf('%02x', @columns)}" +
  19 + "#{picture.join(BetaBrite::Base::CR)}#{BetaBrite::Base::CR}"
  20 + end
  21 + alias :to_str :to_s
  22 + end
  23 + end
  24 +end
36 lib/betabrite/files/stringfile.rb
... ... @@ -0,0 +1,36 @@
  1 +module BetaBrite
  2 + module Files
  3 + class String
  4 + COMMAND_CODE = 'G'
  5 +
  6 + attr_accessor :label, :message
  7 +
  8 + def initialize(label = nil, message = nil, &block)
  9 + @label = label
  10 + @message = message
  11 + instance_eval(&block) if block
  12 + end
  13 +
  14 + def puts(some_string)
  15 + @message = @message ? @message + some_string : some_string
  16 + end
  17 +
  18 + def string(some_string)
  19 + BetaBrite::String.new(some_string)
  20 + end
  21 +
  22 + ::BetaBrite::String.constants.each do |constant|
  23 + next unless constant =~ /^[A-Z_]*$/
  24 + define_method(:"#{constant.downcase}") do
  25 + ::BetaBrite::String.const_get(constant)
  26 + end
  27 + end
  28 +
  29 + def to_s
  30 + "#{BetaBrite::Base::STX}#{COMMAND_CODE}#{@label.to_s}" +
  31 + "#{@message.to_s}#{BetaBrite::Base::ETX}"
  32 + end
  33 + alias :to_str :to_s
  34 + end
  35 + end
  36 +end
138 lib/betabrite/files/textfile.rb
... ... @@ -0,0 +1,138 @@
  1 +module BetaBrite
  2 + module Files
  3 + class Text
  4 + WRITE = 0x41.chr
  5 + READ = 0x42.chr
  6 +
  7 + class Position
  8 + MIDDLE = 0x20.chr
  9 + TOP = 0x22.chr
  10 + BOTTOM = 0x26.chr
  11 + FILL = 0x30.chr
  12 + LEFT = 0x31.chr
  13 + RIGHT = 0x32.chr
  14 + end
  15 +
  16 + class Mode
  17 + # Standard Modes
  18 + ROTATE = 0x61.chr # Message travels right to left
  19 + HOLD = 0x62.chr # Message remains stationary
  20 + FLASH = 0x63.chr # Message remains stationary and flashes
  21 + ROLL_UP = 0x65.chr # Message is pushed up by new message
  22 + ROLL_DOWN = 0x66.chr # Message is pushed down by new message
  23 + ROLL_LEFT = 0x67.chr # Message is pushed left by a new message
  24 + ROLL_RIGHT = 0x68.chr # Message is pushed right by a new message
  25 + WIPE_UP = 0x69.chr # Message is wiped over bottom to top
  26 + WIPE_DOWN = 0x6A.chr # Message is wiped over top to bottom
  27 + WIPE_LEFT = 0x6B.chr # Message is wiped over right to left
  28 + WIPE_RIGHT = 0x6C.chr # Message is wiped over left to right
  29 + SCROLL = 0x6D.chr # New message pushes up if 2 line sign
  30 + AUTOMODE = 0x6F.chr # Various modes are called automatically
  31 + ROLL_IN = 0x70.chr # Message pushed toward center of display
  32 + ROLL_OUT = 0x71.chr # Message pushed away from center of display
  33 + WIPE_IN = 0x72.chr # Message wiped over in inward motion
  34 + WIPE_OUT = 0x73.chr # Message wiped over in outward motion
  35 + COMPRESSED_ROTATE = 0x74.chr # Left to right, chars half normal width
  36 + EXPLODE = 0x75.chr # Message flies apart (Alpha 3.0)
  37 + CLOCK = 0x76.chr # Wipe in clockwise direction (Alpha 3.0)
  38 +
  39 + # Special Modes
  40 + TWINKLE = 0x6E.chr << 0x30.chr # Message will twinkle
  41 + SPARKLE = 0x6E.chr << 0x31.chr # Message will sparkle
  42 + SNOW = 0x6E.chr << 0x32.chr # Message will snow
  43 + INTERLOCK = 0x6E.chr << 0x33.chr # Message will interlock
  44 + SWITCH = 0x6E.chr << 0x34.chr # Message will switch
  45 + SLIDE = 0x6E.chr << 0x35.chr # Message will slide
  46 + SPRAY = 0x6E.chr << 0x36.chr # Message will spray across
  47 + STARBURST = 0x6E.chr << 0x37.chr # Explodes message to screen
  48 + WELCOME = 0x6E.chr << 0x38.chr # The world "Welcome" is written
  49 + SLOT_MACHINE= 0x6E.chr << 0x39.chr # Slot Machine shows up
  50 + NEWS_FLASH = 0x6E.chr << 0x3A.chr # News flash animation
  51 + TRUMPET = 0x6E.chr << 0x3B.chr # Trumpet animation
  52 + CYCLE_COLORS= 0x6E.chr << 0x43.chr # Color changes from one to another
  53 +
  54 + # Special Graphics
  55 + THANK_YOU = [0x6E, 0x53].pack('C*') # "Thank You" in script
  56 + FLAG = [0x6E, 0x54].pack('C*') # American Flag
  57 + NO_SMOKING = [0x6E, 0x55].pack('C*') # No smoking
  58 + DRINK_DRIVE = [0x6E, 0x56].pack('C*') # Don't drink and drive
  59 + ANIMAL_ANIM = [0x6E, 0x57].pack('C*') # Animal animation
  60 + FIREWORKS = [0x6E, 0x58].pack('C*') # Fireworks animation
  61 + BALLOONS = [0x6E, 0x59].pack('C*') # Balloon animation
  62 + CHERRY_BOMB = [0x6E, 0x5A].pack('C*') # A bomb animation or a smile
  63 + SMILE = [0x6E, 0x5A].pack('C*') # A bomb animation or a smile
  64 + end
  65 +
  66 + attr_accessor :label, :position, :mode, :message
  67 +
  68 + def initialize(label = 'A', &block)
  69 + @position = Position::MIDDLE
  70 + @label = label
  71 + @message = nil
  72 + @mode = Mode::ROTATE
  73 + instance_eval(&block) if block
  74 + end
  75 +
  76 + def puts(some_string)
  77 + @message = @message ? @message + some_string : some_string
  78 + end
  79 +
  80 + def string(some_string)
  81 + BetaBrite::String.new(some_string)
  82 + end
  83 +
  84 + def stringfile(label)
  85 + "#{BetaBrite::Base::DLE}#{label}"
  86 + end
  87 +
  88 + def dotsfile(label)
  89 + "#{BetaBrite::Base::STRING}#{label}"
  90 + end
  91 +
  92 + def to_s
  93 + "#{combine}#{checksum(combine)}"
  94 + end
  95 +
  96 + def checksum(string)
  97 + total = 0
  98 + 0.upto(string.length - 1) do |i|
  99 + total += string[i]
  100 + end
  101 +
  102 + sprintf("%04x", total).upcase
  103 + end
  104 +
  105 + alias :inspect :to_s
  106 +
  107 + Mode.constants.each do |constant|
  108 + next unless constant =~ /^[A-Z_]*$/
  109 + define_method(:"#{constant.downcase}") do
  110 + puts constant
  111 + @mode = Mode.const_get(constant)
  112 + self
  113 + end
  114 + end
  115 +
  116 + Position.constants.each do |constant|
  117 + next unless constant =~ /^[A-Z_]*$/
  118 + define_method(:"#{constant.downcase}") do
  119 + @position = Position.const_get(constant)
  120 + self
  121 + end
  122 + end
  123 +
  124 + ::BetaBrite::String.constants.each do |constant|
  125 + next unless constant =~ /^[A-Z_]*$/
  126 + define_method(:"#{constant.downcase}") do
  127 + ::BetaBrite::String.const_get(constant)
  128 + end
  129 + end
  130 +
  131 + private
  132 + def combine
  133 + "#{BetaBrite::Base::STX}#{WRITE}#{@label}#{BetaBrite::Base::ESC}" <<
  134 + "#{@position}#{@mode}#{@message}#{BetaBrite::Base::ETX}"
  135 + end
  136 + end
  137 + end
  138 +end
6 lib/memory/memory.rb → lib/betabrite/memory.rb
... ... @@ -1,4 +1,4 @@
1   -class BetaBrite
  1 +module BetaBrite
2 2 class Memory
3 3 COMMAND_CODE = "E$"
4 4 TEXT = 'A'
@@ -7,7 +7,7 @@ class Memory
7 7 LOCKED = 'L'
8 8 UNLOCKED = 'U'
9 9 def self.clear
10   - BetaBrite::STX << COMMAND_CODE
  10 + BetaBrite::Base::STX << COMMAND_CODE
11 11 end
12 12
13 13 attr_accessor :label, :type, :locked, :size, :time
@@ -91,7 +91,7 @@ def initialize(label, rows, columns)
91 91
92 92 class Clear < Memory
93 93 def to_s
94   - "#{BetaBrite::STX}#{COMMAND_CODE}"
  94 + "#{BetaBrite::Base::STX}#{COMMAND_CODE}"
95 95 end
96 96 end
97 97 end
2  lib/string.rb → lib/betabrite/string.rb
... ... @@ -1,4 +1,4 @@
1   -class BetaBrite
  1 +module BetaBrite
2 2 # This class encapsulates a string and attributes about the string such as
3 3 # color, character set, and also contains special characters.
4 4 class String
4 lib/betabrite/usb.rb
... ... @@ -1,5 +1,5 @@
1   -class BetaBrite
2   - class USB < BetaBrite
  1 +module BetaBrite
  2 + class USB < Base
3 3 # USB Device Codes
4 4 PRODUCT_ID = 0x1234
5 5 VENDOR_ID = 0x8765
22 lib/files/dotsfile.rb
... ... @@ -1,22 +0,0 @@
1   -class BetaBrite
2   - class DotsFile
3   - COMMAND_CODE = 0x49.chr
4   -
5   - attr_accessor :label, :rows, :columns, :picture
6   -
7   - def initialize(label, rows, columns, picture, &block)
8   - @label = label
9   - @rows = rows
10   - @columns = columns
11   - @picture = picture
12   - instance_eval(&block) if block
13   - end
14   -
15   - def to_s
16   - string = "#{BetaBrite::STX}#{COMMAND_CODE}#{@label.to_s}" +
17   - "#{sprintf('%02x', @rows)}#{sprintf('%02x', @columns)}" +
18   - "#{picture.join(BetaBrite::CR)}#{BetaBrite::CR}"
19   - end
20   - alias :to_str :to_s
21   - end
22   -end
34 lib/files/stringfile.rb
... ... @@ -1,34 +0,0 @@
1   -class BetaBrite
2   - class StringFile
3   - COMMAND_CODE = 'G'
4   -
5   - attr_accessor :label, :message
6   -
7   - def initialize(label = nil, message = nil, &block)
8   - @label = label
9   - @message = message
10   - instance_eval(&block) if block
11   - end
12   -
13   - def puts(some_string)
14   - @message = @message ? @message + some_string : some_string
15   - end
16   -
17   - def string(some_string)
18   - BetaBrite::String.new(some_string)
19   - end
20   -
21   - ::BetaBrite::String.constants.each do |constant|
22   - next unless constant =~ /^[A-Z_]*$/
23   - define_method(:"#{constant.downcase}") do
24   - ::BetaBrite::String.const_get(constant)
25   - end
26   - end
27   -
28   - def to_s
29   - "#{BetaBrite::STX}#{COMMAND_CODE}#{@label.to_s}" +
30   - "#{@message.to_s}#{BetaBrite::ETX}"
31   - end
32   - alias :to_str :to_s
33   - end
34   -end
136 lib/files/textfile.rb
... ... @@ -1,136 +0,0 @@
1   -class BetaBrite
2   - class TextFile
3   - WRITE = 0x41.chr
4   - READ = 0x42.chr
5   -
6   - class Position
7   - MIDDLE = 0x20.chr
8   - TOP = 0x22.chr
9   - BOTTOM = 0x26.chr
10   - FILL = 0x30.chr
11   - LEFT = 0x31.chr
12   - RIGHT = 0x32.chr
13   - end
14   -
15   - class Mode
16   - # Standard Modes
17   - ROTATE = 0x61.chr # Message travels right to left
18   - HOLD = 0x62.chr # Message remains stationary
19   - FLASH = 0x63.chr # Message remains stationary and flashes
20   - ROLL_UP = 0x65.chr # Message is pushed up by new message
21   - ROLL_DOWN = 0x66.chr # Message is pushed down by new message
22   - ROLL_LEFT = 0x67.chr # Message is pushed left by a new message
23   - ROLL_RIGHT = 0x68.chr # Message is pushed right by a new message
24   - WIPE_UP = 0x69.chr # Message is wiped over bottom to top
25   - WIPE_DOWN = 0x6A.chr # Message is wiped over top to bottom
26   - WIPE_LEFT = 0x6B.chr # Message is wiped over right to left
27   - WIPE_RIGHT = 0x6C.chr # Message is wiped over left to right
28   - SCROLL = 0x6D.chr # New message pushes up if 2 line sign
29   - AUTOMODE = 0x6F.chr # Various modes are called automatically
30   - ROLL_IN = 0x70.chr # Message pushed toward center of display
31   - ROLL_OUT = 0x71.chr # Message pushed away from center of display
32   - WIPE_IN = 0x72.chr # Message wiped over in inward motion
33   - WIPE_OUT = 0x73.chr # Message wiped over in outward motion
34   - COMPRESSED_ROTATE = 0x74.chr # Left to right, chars half normal width
35   - EXPLODE = 0x75.chr # Message flies apart (Alpha 3.0)
36   - CLOCK = 0x76.chr # Wipe in clockwise direction (Alpha 3.0)
37   -
38   - # Special Modes
39   - TWINKLE = 0x6E.chr << 0x30.chr # Message will twinkle
40   - SPARKLE = 0x6E.chr << 0x31.chr # Message will sparkle
41   - SNOW = 0x6E.chr << 0x32.chr # Message will snow
42   - INTERLOCK = 0x6E.chr << 0x33.chr # Message will interlock
43   - SWITCH = 0x6E.chr << 0x34.chr # Message will switch
44   - SLIDE = 0x6E.chr << 0x35.chr # Message will slide
45   - SPRAY = 0x6E.chr << 0x36.chr # Message will spray across
46   - STARBURST = 0x6E.chr << 0x37.chr # Explodes message to screen
47   - WELCOME = 0x6E.chr << 0x38.chr # The world "Welcome" is written
48   - SLOT_MACHINE= 0x6E.chr << 0x39.chr # Slot Machine shows up
49   - NEWS_FLASH = 0x6E.chr << 0x3A.chr # News flash animation
50   - TRUMPET = 0x6E.chr << 0x3B.chr # Trumpet animation
51   - CYCLE_COLORS= 0x6E.chr << 0x43.chr # Color changes from one to another
52   -
53   - # Special Graphics
54   - THANK_YOU = [0x6E, 0x53].pack('C*') # "Thank You" in script
55   - FLAG = [0x6E, 0x54].pack('C*') # American Flag
56   - NO_SMOKING = [0x6E, 0x55].pack('C*') # No smoking
57   - DRINK_DRIVE = [0x6E, 0x56].pack('C*') # Don't drink and drive
58   - ANIMAL_ANIM = [0x6E, 0x57].pack('C*') # Animal animation
59   - FIREWORKS = [0x6E, 0x58].pack('C*') # Fireworks animation
60   - BALLOONS = [0x6E, 0x59].pack('C*') # Balloon animation
61   - CHERRY_BOMB = [0x6E, 0x5A].pack('C*') # A bomb animation or a smile
62   - SMILE = [0x6E, 0x5A].pack('C*') # A bomb animation or a smile
63   - end
64   -
65   - attr_accessor :label, :position, :mode, :message
66   -
67   - def initialize(label = 'A', &block)
68   - @position = Position::MIDDLE
69   - @label = label
70   - @message = nil
71   - @mode = Mode::ROTATE
72   - instance_eval(&block) if block
73   - end
74   -
75   - def puts(some_string)
76   - @message = @message ? @message + some_string : some_string
77   - end
78   -
79   - def string(some_string)
80   - BetaBrite::String.new(some_string)
81   - end
82   -
83   - def stringfile(label)
84   - "#{BetaBrite::DLE}#{label}"
85   - end
86   -
87   - def dotsfile(label)
88   - "#{BetaBrite::STRING}#{label}"
89   - end
90   -
91   - def to_s
92   - "#{combine}#{checksum(combine)}"
93   - end
94   -
95   - def checksum(string)
96   - total = 0
97   - 0.upto(string.length - 1) do |i|
98   - total += string[i]
99   - end
100   -
101   - sprintf("%04x", total).upcase
102   - end
103   -
104   - alias :inspect :to_s
105   -
106   - Mode.constants.each do |constant|
107   - next unless constant =~ /^[A-Z_]*$/
108   - define_method(:"#{constant.downcase}") do
109   - puts constant
110   - @mode = Mode.const_get(constant)
111   - self
112   - end
113   - end
114   -
115   - Position.constants.each do |constant|
116   - next unless constant =~ /^[A-Z_]*$/
117   - define_method(:"#{constant.downcase}") do
118   - @position = Position.const_get(constant)
119   - self
120   - end
121   - end
122   -
123   - ::BetaBrite::String.constants.each do |constant|
124   - next unless constant =~ /^[A-Z_]*$/
125   - define_method(:"#{constant.downcase}") do
126   - ::BetaBrite::String.const_get(constant)
127   - end
128   - end
129   -
130   - private
131   - def combine
132   - "#{BetaBrite::STX}#{WRITE}#{@label}#{BetaBrite::ESC}" <<
133   - "#{@position}#{@mode}#{@message}#{BetaBrite::ETX}"
134   - end
135   - end
136   -end
2  test/test_many_mem.rb
@@ -6,7 +6,7 @@
6 6
7 7 class ManyMemoryAllocTest < Test::Unit::TestCase
8 8 def setup
9   - @sign = BetaBrite.new
  9 + @sign = BetaBrite::Base.new
10 10 @sign.sleep_time = 0
11 11 end
12 12
2  test/test_memory.rb
@@ -6,7 +6,7 @@
6 6
7 7 class MemoryAllocTest < Test::Unit::TestCase
8 8 def setup
9   - @sign = BetaBrite.new
  9 + @sign = BetaBrite::Base.new
10 10 @sign.sleep_time = 0
11 11 end
12 12
4 test/test_set_string.rb
@@ -6,7 +6,7 @@
6 6
7 7 class SetStringTest < Test::Unit::TestCase
8 8 def setup
9   - @sign = BetaBrite.new
  9 + @sign = BetaBrite::Base.new
10 10 @sign.sleep_time = 0
11 11 end
12 12
@@ -28,7 +28,7 @@ def test_many_mem
28 28 '3.37 ',
29 29 '16.47 '
30 30 ].each_with_index do |price,idx|
31   - @sign.string_files << BetaBrite::StringFile.new(idx, price)
  31 + @sign.string_files << BetaBrite::Files::String.new(idx, price)
32 32 end
33 33
34 34 assert_equal('11045.28 ', @sign.string_files[0].message)
8 test/test_text_file.rb
@@ -5,13 +5,15 @@
5 5 require 'betabrite'
6 6
7 7 class TextFileTest < Test::Unit::TestCase
  8 + include BetaBrite::Files
  9 +
8 10 def test_const_dsl
9   - tf = BetaBrite::TextFile.new {
  11 + tf = Text.new {
10 12 roll_down()
11 13 middle()
12 14 }
13 15
14   - assert_equal(BetaBrite::TextFile::Position::MIDDLE, tf.position)
15   - assert_equal(BetaBrite::TextFile::Mode::ROLL_DOWN, tf.mode)
  16 + assert_equal(Text::Position::MIDDLE, tf.position)
  17 + assert_equal(Text::Mode::ROLL_DOWN, tf.mode)
16 18 end
17 19 end

0 comments on commit 46247fe

Please sign in to comment.
Something went wrong with that request. Please try again.