Class: Mikrotik::Protocol::Sentence
- Inherits:
-
Hash
- Object
- Hash
- Mikrotik::Protocol::Sentence
- Defined in:
- lib/mikrotik/protocol/sentence.rb
Instance Method Summary (collapse)
-
- (Object) [](key)
Fetches any returned value in this reply, converting it to a ruby type first.
-
- (Boolean) completely_done?
Is this reply only informing that a command is done, and contains no other data?.
-
- (Boolean) done?
Is this the last reply for a command?.
-
- (Boolean) empty?
Sentence only contains a zero length word.
-
- (Object) result(key)
Fetches a returned property.
-
- (nil, Integer) tag
Retreives the reply's command tag.
-
- (Boolean) tagged?
Does the reply have a command tag associated with it?.
-
- (Boolean) trap?
Is this informing of an error that should be trapped?.
Instance Method Details
- (Object) [](key)
Fetches any returned value in this reply, converting it to a ruby type first
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/mikrotik/protocol/sentence.rb', line 48 def [](key) return nil unless key?(key) case key when '.tag' fetch(key).to_i else value = fetch(key) #case value #when /\d+/ # value.to_i #when /\d+.\d+/ # value.to_f #when 'true' # true #when 'false' # false #else # value #end end end |
- (Boolean) completely_done?
Is this reply only informing that a command is done, and contains no other data?
17 18 19 |
# File 'lib/mikrotik/protocol/sentence.rb', line 17 def completely_done? size == 2 and done? and tagged? end |
- (Boolean) done?
Is this the last reply for a command?
11 12 13 |
# File 'lib/mikrotik/protocol/sentence.rb', line 11 def done? key?('!done') end |
- (Boolean) empty?
Sentence only contains a zero length word
5 6 7 |
# File 'lib/mikrotik/protocol/sentence.rb', line 5 def empty? super || false end |
- (Object) result(key)
Fetches a returned property
43 44 45 |
# File 'lib/mikrotik/protocol/sentence.rb', line 43 def result(key) self["=#{key}"] end |
- (nil, Integer) tag
Retreives the reply's command tag
37 38 39 |
# File 'lib/mikrotik/protocol/sentence.rb', line 37 def tag tagged? ? self['.tag'] : nil end |
- (Boolean) tagged?
Does the reply have a command tag associated with it?
29 30 31 |
# File 'lib/mikrotik/protocol/sentence.rb', line 29 def tagged? key?('.tag') end |
- (Boolean) trap?
Is this informing of an error that should be trapped?
23 24 25 |
# File 'lib/mikrotik/protocol/sentence.rb', line 23 def trap? key?('!trap') end |