Sha256: 6eaa64452632ba1257b196a58df1e163d77be7227c9c72cabd79e1c86cb1f70c
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
#-- # Ruby Whois # # An intelligent pure Ruby WHOIS client and parser. # # Copyright (c) 2009-2011 Simone Carletti <weppos@weppos.net> #++ require 'strscan' module Whois class Record class Parser module Scanners # 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) 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
whois-2.2.0 | lib/whois/record/parser/scanners/ast.rb |
whois-2.1.0 | lib/whois/record/parser/scanners/ast.rb |