class BetaBrite::Files::Text

Constants

READ
WRITE

Attributes

label[RW]
message[RW]
mode[RW]
position[RW]

Public Class Methods

new(label = 'A', &block) click to toggle source
# File lib/betabrite/files/text.rb, line 70
def initialize(label = 'A', &block)
  @position = Position::MIDDLE
  @label = label
  @message = nil
  @mode  = Mode::ROTATE
  instance_eval(&block) if block
end

Public Instance Methods

checksum(string) click to toggle source
# File lib/betabrite/files/text.rb, line 90
def checksum(string)
  total = 0
  string.unpack('C*').each { |i|
    total += i
  }

  sprintf("%04X", total)
end
dotsfile(label) click to toggle source
# File lib/betabrite/files/text.rb, line 82
def dotsfile(label)
"#{BetaBrite::Device::STRING}#{label}"
end
stringfile(label) click to toggle source
# File lib/betabrite/files/text.rb, line 78
def stringfile(label)
"#{BetaBrite::Device::DLE}#{label}"
end
to_s() click to toggle source
# File lib/betabrite/files/text.rb, line 86
def to_s
"#{combine}#{checksum(combine)}"
end

Private Instance Methods

combine() click to toggle source
# File lib/betabrite/files/text.rb, line 116
def combine
  "#{BetaBrite::Device::STX}#{WRITE}#{@label}#{BetaBrite::Device::ESC}" +
    "#{@position}#{@mode}#{@message}#{BetaBrite::Device::ETX}"
end