Sha256: 3eb3e346be963ec40d0e254067ccd124b8c90ee9173c76a0a47d68ac49c52ce5
Contents?: true
Size: 1.32 KB
Versions: 47
Compression:
Stored size: 1.32 KB
Contents
# # = Ruby Whois # # An intelligent pure Ruby WHOIS client and parser. # # # Category:: Net # Package:: Whois # Author:: Simone Carletti <weppos@weppos.net> # License:: MIT License # #-- # #++ require 'strscan' module Whois class Answer class Parser # The Ast module tries to emulate a super-simple Abstract Syntax Tree structure # including method for accessing ast nodes. # # == Usage # # Include the Ast module and provide a <tt>parse</tt> instance method. # <tt>parse</tt> should returns a Hash representing the AST. # # def parse # Scanner.new.parse # end # # => { "created_on" => "2009-12-12", ... } # # Now you can access the AST using the <tt>node</tt> method. # # node "created_on" # # => "2009-12-12" # # node? "created_on" # # => true # # node? "created_at" # # => false # module Ast def ast @ast ||= parse end def node(key, &block) if block_given? value = ast[key] value = yield(value) unless value.nil? value else ast[key] end end def node?(key) !ast[key].nil? end end end end end
Version data entries
47 entries across 47 versions & 1 rubygems