Class: PageObjectify::DOMToRuby

Inherits:
Object
  • Object
show all
Includes:
ASTMaker, Logging
Defined in:
lib/page-objectify/dom_to_ruby.rb

Overview

Takes an Array of DOM elements and generates Ruby code (page class containing PageObject::Accessors)

Instance Method Summary collapse

Methods included from Logging

#logger

Methods included from ASTMaker

#s

Constructor Details

#initialize(dom, config) ⇒ DOMToRuby

Returns a new instance of DOMToRuby.



13
14
15
16
# File 'lib/page-objectify/dom_to_ruby.rb', line 13

def initialize(dom, config)
  @dom = dom
  @config = config
end

Instance Method Details

#unparseObject

Generate Ruby source as a String



19
20
21
22
23
24
25
# File 'lib/page-objectify/dom_to_ruby.rb', line 19

def unparse
  tree = s(:class,
    *first_line,
    s(:begin, *accessors)
  )
  Unparser.unparse(tree)
end