Class: DNSCheck::Output
- Inherits:
-
Object
- Object
- DNSCheck::Output
- Defined in:
- lib/dns-check/output.rb
Instance Method Summary collapse
-
#initialize ⇒ Output
constructor
A new instance of Output.
- #insert(*msg) ⇒ Object
- #pretty_print(msg) ⇒ Object
- #print_msg(msg) ⇒ Object
Constructor Details
#initialize ⇒ Output
Returns a new instance of Output.
7 |
# File 'lib/dns-check/output.rb', line 7 def initialize; end |
Instance Method Details
#insert(*msg) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dns-check/output.rb', line 13 def insert(*msg) $stdout = StringIO.new yield unless $stdout.string.empty? STDOUT.print $stdout.string STDOUT.flush end ensure $stdout = STDOUT end |
#pretty_print(msg) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dns-check/output.rb', line 26 def pretty_print msg #FIXME redundant, catch nil instead of has_key if msg[3] && COUNTRY_CODES.has_key?(msg[3]) msg[0] = "/#{msg[0]}" if !msg[0].empty? #FIXME cheap workaround around frozen string msg[0] = msg[0].dup msg[0].prepend(msg[3].resolve_country_code) end print msg[0] + "#{DNSCheck.config[:sep]}" + msg[1] print "#{DNSCheck.config[:sep]}" + msg[2] if DNSCheck.config[:show_ns] print "\n" end |
#print_msg(msg) ⇒ Object
9 10 11 |
# File 'lib/dns-check/output.rb', line 9 def print_msg msg pretty_print msg end |