Files

Class/Module Index [+]

Quicksearch

Whois::Record::Scanners::Scannable

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

Usage

Include the Scannable module and set the `self.scanner` value.

class ParserFoo
  include Scannable

  self.scanner = ScannerFoo
end

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 Class Methods

included(base) click to toggle source
# File lib/whois/record/scanners/scannable.rb, line 43
def self.included(base)
  base.class_attribute :scanner
end

Public Instance Methods

node(key) click to toggle source
# File lib/whois/record/scanners/scannable.rb, line 47
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/scannable.rb, line 57
def node?(key)
  !ast[key].nil?
end
parse() click to toggle source
# File lib/whois/record/scanners/scannable.rb, line 61
def parse
  self.scanner.new(content_for_scanner).parse
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.