Class: SML::MessageBody
- Inherits:
-
Object
- Object
- SML::MessageBody
- Defined in:
- lib/ruby-sml/sml-messagebody.rb
Class Method Summary collapse
Class Method Details
.construct(array_rep) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ruby-sml/sml-messagebody.rb', line 15 def self.construct(array_rep) return nil if array_rep.nil? choice = array_rep.shift array_rep.shift unless choice.nil? body_array = array_rep.shift return case choice when 0x0100 SML::PublicOpen::Request.construct(body_array) when 0x0101 SML::PublicOpen::Response.construct(body_array) when 0x0200 SML::PublicClose::Request.construct(body_array) when 0x0201 SML::PublicClose::Response.construct(body_array) when 0x0300 SML::GetProfilePack::Request.construct(body_array) when 0x0301 SML::GetProfilePack::Response.construct(body_array) when 0x0400 SML::GetProfileList::Request.construct(body_array) when 0x0401 SML::GetProfileList::Response.construct(body_array) when 0x0500 SML::GetProcParameter::Request.construct(body_array) when 0x0501 SML::GetProcParameter::Response.construct(body_array) when 0x0600 SML::SetProcParameter::Request.construct(body_array) when 0x0601 nil # SML::SetProcParameter::Response.construct(body_array) # SML_SetProcParameter.Res is supposed to exist, but the standard doesn't define it # respones to SetProcParameter.Req are supposed to be SML_Attention.Res' when 0x0700 SML::GetList::Request.construct(body_array) when 0x0701 SML::GetList::Response.construct(body_array) when 0xff01 SML::Attention::Response.construct(body_array) end end |
.to_a(object) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/ruby-sml/sml-messagebody.rb', line 56 def self.to_a(object) choice = case object when SML::PublicOpen::Request 0x0100 when SML::PublicOpen::Response 0x0101 when SML::PublicClose::Request 0x0200 when SML::PublicClose::Response 0x0201 when SML::GetProfilePack::Request 0x0300 when SML::GetProfilePack::Response 0x0301 when SML::GetProfileList::Request 0x0400 when SML::GetProfileList::Response 0x0401 when SML::GetProcParameter::Request 0x0500 when SML::GetProcParameter::Response 0x0501 when SML::SetProcParameter::Request 0x0600 when SML::GetList::Request 0x0700 when SML::GetList::Response 0x0701 when SML::Attention::Response 0xff01 end result = [] << choice result << :uint32 unless choice.nil? return result << object.to_a end |