You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
555 B
Crystal
23 lines
555 B
Crystal
require "./ltnp_record"
|
|
|
|
class LtnpOperator
|
|
def initialize(cmd_output : String)
|
|
records = cmd_output.each_line
|
|
records = records.each.select(/^tcp/)
|
|
@ltnp_records = Array(LtnpRecord).new
|
|
records.each { |s| @ltnp_records << LtnpRecord.new s }
|
|
end
|
|
|
|
def say_hi
|
|
@ltnp_records.each { |r| puts r.to_s }
|
|
end
|
|
|
|
def get_port_record(port : String) : LtnpRecord | Nil
|
|
@ltnp_records.find { |r| r.port == port }
|
|
end
|
|
|
|
def search_p_name(p_name : String) : LtnpRecord | Nil
|
|
@ltnp_records.find { |r| r.p_name == p_name }
|
|
end
|
|
end
|