Class: Extface::Driver::EltradeTmU220::Frame

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/models/extface/driver/eltrade_tm_u220.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer) ⇒ Frame

Returns a new instance of Frame.



264
265
266
267
268
269
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 264

def initialize(buffer)
  if match = buffer.match(/\xAA\x55(.{1})(.{1})(.{1})(.{1})(.*)(.{1})$/nm)
    @frame = match.to_a.first
    @addr, @seq, @cmd, @len, @data, @check_sum = match.captures
  end
end

Instance Attribute Details

#addr ⇒ Object (readonly)

Returns the value of attribute addr.



257
258
259
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 257

def addr
  @addr
end

#check_sum ⇒ Object (readonly)

Returns the value of attribute check_sum.



257
258
259
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 257

def check_sum
  @check_sum
end

#cmd ⇒ Object (readonly)

Returns the value of attribute cmd.



257
258
259
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 257

def cmd
  @cmd
end

#data ⇒ Object (readonly)

Returns the value of attribute data.



257
258
259
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 257

def data
  @data
end

#frame ⇒ Object (readonly)

Returns the value of attribute frame.



257
258
259
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 257

def frame
  @frame
end

#len ⇒ Object (readonly)

Returns the value of attribute len.



257
258
259
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 257

def len
  @len
end

#seq ⇒ Object (readonly)

Returns the value of attribute seq.



257
258
259
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 257

def seq
  @seq
end

Instance Method Details

#busy? ⇒ Boolean

Returns:

  • (Boolean)


275
276
277
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 275

def busy?
  !ready?
end

#ready? ⇒ Boolean

Returns:

  • (Boolean)


271
272
273
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 271

def ready?
  @ready || true
end