Sha256: 7e08131cde52a527851c8306376911e279f6b2adf39a70cd01bf5f9d18772343
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
#-- # Ruby Whois # # An intelligent pure Ruby WHOIS client and parser. # # Copyright (c) 2009-2012 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 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 private def ast @ast ||= parse end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
whois-2.4.0 | lib/whois/record/parser/scanners/ast.rb |
whois-2.3.0 | lib/whois/record/parser/scanners/ast.rb |