Class: Lib::TL1::Huawei::Message::Output
- Inherits:
-
Message::Output
- Object
- Message::Output
- Lib::TL1::Huawei::Message::Output
- Extended by:
- Forwardable
- Defined in:
- lib/lib/tl1/huawei/message/output.rb
Class Method Summary collapse
Instance Method Summary collapse
- #blkcount ⇒ Object
- #blktag ⇒ Object
- #blktotal ⇒ Object
- #en ⇒ Object (also: #error_code, #return_code, #error_number)
- #endesc ⇒ Object
-
#initialize(message = nil, sid: nil, date: nil, time: nil, ctag: nil, cc: nil, text_block: nil) ⇒ Output
constructor
A new instance of Output.
- #response ⇒ Object (also: #response_message)
- #title ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(message = nil, sid: nil, date: nil, time: nil, ctag: nil, cc: nil, text_block: nil) ⇒ Output
Returns a new instance of Output.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/lib/tl1/huawei/message/output.rb', line 17 def initialize( = nil, sid: nil, date: nil, time: nil, ctag: nil, cc: nil, text_block: nil) if .nil? super sid: sid, date: date, time: time, ctag: ctag, cc: cc, text_block: text_block else = Lib::TL1::Message.parse unless .instance_of? Lib::TL1::Message::Output raise ArgumentError, "No implicit conversion form #{message.class.name} to #{self.class.name}" end super( sid: .sid, date: .date, time: .time, ctag: .ctag, cc: .cc, text_block: .text_block ) end raise Lib::TL1::Huawei::StandardError.new(self.endesc, self.error_number) unless self.error_number.to_i == 0 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object (private)
116 117 118 119 120 121 122 123 |
# File 'lib/lib/tl1/huawei/message/output.rb', line 116 def method_missing(method_name, *args) super if (blktotal.to_i > 1) || en.to_i.positive? if response.first.respond_to? method_name response.first.send method_name else super end end |
Class Method Details
.parse(message) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/lib/tl1/huawei/message/output.rb', line 98 def self.parse() = Lib::TL1::Message.parse unless .instance_of? Lib::TL1::Message::Output raise ArgumentError, "No implicit conversion of #{message.class.name} to #{self.class.name}" end new( sid: .sid, date: .date, time: .time, ctag: .ctag, cc: .cc, text_block: .text_block ) end |
Instance Method Details
#blkcount ⇒ Object
76 77 78 79 |
# File 'lib/lib/tl1/huawei/message/output.rb', line 76 def blkcount parse_quoted_line unless defined? @blkcount @blkcount end |
#blktag ⇒ Object
71 72 73 74 |
# File 'lib/lib/tl1/huawei/message/output.rb', line 71 def blktag parse_text_block unless defined? @blktag @blktag end |
#blktotal ⇒ Object
81 82 83 84 |
# File 'lib/lib/tl1/huawei/message/output.rb', line 81 def blktotal parse_quoted_line unless defined? @blktotal @blktotal end |
#en ⇒ Object Also known as: error_code, return_code, error_number
57 58 59 60 |
# File 'lib/lib/tl1/huawei/message/output.rb', line 57 def en parse_text_block unless defined? @en @en end |
#endesc ⇒ Object
66 67 68 69 |
# File 'lib/lib/tl1/huawei/message/output.rb', line 66 def endesc parse_text_block unless defined? @endesc @endesc end |
#response ⇒ Object Also known as: response_message
91 92 93 94 |
# File 'lib/lib/tl1/huawei/message/output.rb', line 91 def response parse_result unless defined? @response @response end |
#title ⇒ Object
86 87 88 89 |
# File 'lib/lib/tl1/huawei/message/output.rb', line 86 def title parse_result unless defined? @title @title end |
#to_h ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/lib/tl1/huawei/message/output.rb', line 38 def to_h { sid: self.sid.to_s, date: self.date.to_s, time: self.time.to_s, ctag: self.ctag.to_s, cc: self.cc.to_s, en: self.en, endesc: self.endesc, blktag: self.blktag, blkcount: self.blkcount, blktotal: self.blktotal, title: self.title, response: self.response.map(&:to_h).map do |r| r.transform_values { |v| v.force_encoding('iso-8859-1').encode('utf-8') } end } end |