Class: BetaBrite::Files::Text
- Inherits:
-
Object
- Object
- BetaBrite::Files::Text
- Includes:
- BetaBrite::FileDSL
- Defined in:
- lib/betabrite/files/text.rb
Defined Under Namespace
Constant Summary collapse
- WRITE =
0x41.chr
- READ =
0x42.chr
Instance Attribute Summary collapse
-
#label ⇒ Object
Returns the value of attribute label.
-
#message ⇒ Object
Returns the value of attribute message.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#position ⇒ Object
Returns the value of attribute position.
Instance Method Summary collapse
- #checksum(string) ⇒ Object
- #dotsfile(label) ⇒ Object
-
#initialize(label = 'A', &block) ⇒ Text
constructor
A new instance of Text.
- #stringfile(label) ⇒ Object
- #to_s ⇒ Object
Methods included from BetaBrite::FileDSL
Constructor Details
Instance Attribute Details
#label ⇒ Object
Returns the value of attribute label.
66 67 68 |
# File 'lib/betabrite/files/text.rb', line 66 def label @label end |
#message ⇒ Object
Returns the value of attribute message.
66 67 68 |
# File 'lib/betabrite/files/text.rb', line 66 def @message end |
#mode ⇒ Object
Returns the value of attribute mode.
66 67 68 |
# File 'lib/betabrite/files/text.rb', line 66 def mode @mode end |
#position ⇒ Object
Returns the value of attribute position.
66 67 68 |
# File 'lib/betabrite/files/text.rb', line 66 def position @position end |
Instance Method Details
#checksum(string) ⇒ Object
90 91 92 93 94 95 96 97 |
# 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) ⇒ Object
82 83 84 |
# File 'lib/betabrite/files/text.rb', line 82 def dotsfile(label) "#{BetaBrite::Device::STRING}#{label}" end |
#stringfile(label) ⇒ Object
78 79 80 |
# File 'lib/betabrite/files/text.rb', line 78 def stringfile(label) "#{BetaBrite::Device::DLE}#{label}" end |
#to_s ⇒ Object
86 87 88 |
# File 'lib/betabrite/files/text.rb', line 86 def to_s "#{combine}#{checksum(combine)}" end |