Methods

Files

Class/Module Index [+]

Quicksearch

Whois::Record::Scanners::Nodable

The Nodable module tries to emulate a super-simple Abstract Syntax Tree structure including method for accessing ast nodes.

Usage

Include the Nodable module and provide a parse instance method. parse 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 node method.

node "created_on"
# => "2009-12-12"

node? "created_on"
# => true

node? "created_at"
# => false

Public Instance Methods

node(key) click to toggle source
# File lib/whois/record/scanners/nodable.rb, line 43
def node(key)
  if block_given?
    value = ast[key]
    value = yield(value) unless value.nil?
    value
  else
    ast[key]
  end
end
node?(key) click to toggle source
# File lib/whois/record/scanners/nodable.rb, line 53
def node?(key)
  !ast[key].nil?
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.