Class: TorigoyaKit::Protocol::Frame

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind, buffer) ⇒ Frame

Returns a new instance of Frame.



60
61
62
63
# File 'lib/torigoya_kit/protocol.rb', line 60

def initialize(kind, buffer)
  @kind = kind
  @raw_object = MessagePack.unpack(buffer)
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



64
65
66
# File 'lib/torigoya_kit/protocol.rb', line 64

def kind
  @kind
end

#raw_objectObject (readonly)

Returns the value of attribute raw_object.



64
65
66
# File 'lib/torigoya_kit/protocol.rb', line 64

def raw_object
  @raw_object
end

Instance Method Details

#get_objectObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/torigoya_kit/protocol.rb', line 66

def get_object
  case @kind
  when MessageKindOutputs
    return StreamOutputResult.from_hash(@raw_object)
  when MessageKindResult
    return StreamExecutedResult.from_hash(@raw_object)
  when MessageKindSystemError
    return StreamSystemError.new(@raw_object)
  when MessageKindExit
    return StreamExit.new(@raw_object)

  when MessageKindSystemResult
    return StreamSystemResult.new(@raw_object)
  else
    raise "Protocol :: Result kind(#{kind}) is not supported by clitnt side"
  end
end