class MTik::Reply

A MikroTik API reply is stored as an array of response sentences. Each sentence is a key/value Hash object. The MTik::Reply class is simply a basic Ruby Array with #find_sentence and #find_sentences methods added.

Public Instance Methods

find_sentence(key) click to toggle source

This method is nearly identical to Array.select{|i| i.key?(key)}[0] except that this method short-circuits and returns when the first match is found.

# File lib/mtik/reply.rb, line 43
def find_sentence(key)
  self.each do |sentence|
    return sentence if sentence.key?(key)
  end
  return nil
end
find_sentences(key) click to toggle source

This method is simply an alias for Array.select{|i| i.key?(key)}

# File lib/mtik/reply.rb, line 51
def find_sentences(key)
  return self.select do |sentence|
    sentence.key?(key)
  end
end