Class: BetaBrite::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/memory/memory.rb

Direct Known Subclasses

Clear, Dots, String, Text

Defined Under Namespace

Classes: Clear, Dots, String, Text

Constant Summary collapse

COMMAND_CODE =
"E$"
TEXT =
'A'
STRING =
'B'
DOTS =
'D'
LOCKED =
'L'
UNLOCKED =
'U'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) {|_self| ... } ⇒ Memory

Returns a new instance of Memory.

Yields:

  • (_self)

Yield Parameters:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/memory/memory.rb', line 14

def initialize(opts = {})
  args = {  :label  => 'A',
            :type   => STRING,
            :locked => LOCKED,
            :size   => sprintf("%04x", 0),
            :time   => '0000'
          }.merge opts
  @label  = args[:label]
  @type   = args[:type]
  @locked = args[:locked]
  @size   = args[:size]
  @time   = args[:time]
  yield self if block_given?
end

Instance Attribute Details

#labelObject

Returns the value of attribute label.



13
14
15
# File 'lib/memory/memory.rb', line 13

def label
  @label
end

#lockedObject

Returns the value of attribute locked.



13
14
15
# File 'lib/memory/memory.rb', line 13

def locked
  @locked
end

#sizeObject

Returns the value of attribute size.



13
14
15
# File 'lib/memory/memory.rb', line 13

def size
  @size
end

#timeObject

Returns the value of attribute time.



13
14
15
# File 'lib/memory/memory.rb', line 13

def time
  @time
end

#typeObject

Returns the value of attribute type.



13
14
15
# File 'lib/memory/memory.rb', line 13

def type
  @type
end

Class Method Details

.clearObject



9
10
11
# File 'lib/memory/memory.rb', line 9

def self.clear
  BetaBrite::STX << COMMAND_CODE
end

Instance Method Details

#formatObject Also known as: to_s



29
30
31
32
# File 'lib/memory/memory.rb', line 29

def format
  #BetaBrite::STX << COMMAND_CODE << @label << @type << @locked <<
  @label << @type << @locked << @size.upcase << @time
end