Class: RBase::Columns::LogicalColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/rbase/columns.rb

Instance Attribute Summary

Attributes inherited from Column

#decimal, #name, #offset, #size

Instance Method Summary collapse

Methods inherited from Column

#attach_to, column_for, column_type, #type, type

Constructor Details

#initialize(name, options = {}) ⇒ LogicalColumn

Returns a new instance of LogicalColumn.



155
156
157
# File 'lib/rbase/columns.rb', line 155

def initialize(name, options = {})
  super name, options.merge(:size => 1)
end

Instance Method Details

#inspectObject



178
179
180
# File 'lib/rbase/columns.rb', line 178

def inspect
  "#{name}(boolean)"
end

#pack(value) ⇒ Object



159
160
161
162
163
164
165
# File 'lib/rbase/columns.rb', line 159

def pack(value)
  case value
  when true then 'T'
  when false then 'F'
  else '?'
  end
end

#unpack(data) ⇒ Object



167
168
169
170
171
172
173
174
175
176
# File 'lib/rbase/columns.rb', line 167

def unpack(data)
  case data.upcase
  when 'Y', 'T'
    true
  when 'N', 'F'
    false
  else
    nil
  end
end