class BetaBrite::Device
Constants
- CR
- DLE
- EOT
- ESC
- ETX
- HEADER
Synopsis¶ ↑
This class assembles all packets (different files) and yields the data that needs to be written back to the caller of the BetaBrite#write method.
- MEMORY_CODE
- SIGN_TYPE
Beta Brite sign
- STRING
- STX
Attributes
dots_files[R]
memory[R]
sleep_time[RW]
string_files[R]
text_files[R]
Public Class Methods
new() { |self| ... }
click to toggle source
# File lib/betabrite/device.rb, line 26 def initialize # Default address is "00" which means broadcast to all signs @sign_address = [ 0x30, 0x30 ] @string_files = [] @text_files = [] @dots_files = [] @memory = [] # This shouldn't change except for unit testing @sleep_time = 0 yield self if block_given? end
Public Instance Methods
allocate(&block)
click to toggle source
# File lib/betabrite/device.rb, line 51 def allocate(&block) @memory.push(*(BetaBrite::Memory::Factory.find(&block))) end
clear_memory!()
click to toggle source
# File lib/betabrite/device.rb, line 55 def clear_memory! @memory = [] self.write_memory! end
dotsfile(label, rows = nil, columns = nil, picture = nil, &block)
click to toggle source
# File lib/betabrite/device.rb, line 47 def dotsfile(label, rows = nil, columns = nil, picture = nil, &block) @dots_files << Dots.new(label, rows, columns, picture,&block) end
memory_message()
click to toggle source
# File lib/betabrite/device.rb, line 69 def memory_message "#{header}#{STX}#{MEMORY_CODE}#{@memory.map { |packet| packet.to_s }.join('')}#{tail}" end
message()
click to toggle source
Get the message to be sent to the sign
# File lib/betabrite/device.rb, line 61 def message header + @text_files.each { |tf| tf.to_s }.join('') + @string_files.each { |tf| tf.to_s }.join('') + @dots_files.each { |tf| tf.to_s }.join('') + tail end
stringfile(label, message = nil, &block)
click to toggle source
# File lib/betabrite/device.rb, line 43 def stringfile(label, message = nil, &block) @string_files << Files::String.new(label, message, &block) end
textfile(label = 'A', &block)
click to toggle source
# File lib/betabrite/device.rb, line 39 def textfile(label = 'A', &block) @text_files << Text.new(label, &block) end
Private Instance Methods
header()
click to toggle source
# File lib/betabrite/device.rb, line 75 def header header_str = HEADER.collect { |a| a.chr }.join "#{header_str}#{SIGN_TYPE}#{@sign_address.collect { |a| a.chr }.join}" end
Also aliased as: inspect
tail()
click to toggle source
# File lib/betabrite/device.rb, line 82 def tail EOT end