Class: PageObjectify::DOMToRuby

Inherits:
Object
  • Object
show all
Includes:
ASTMaker
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 ASTMaker

#s

Constructor Details

#initialize(dom, config) ⇒ DOMToRuby

Returns a new instance of DOMToRuby.



11
12
13
14
# File 'lib/page-objectify/dom_to_ruby.rb', line 11

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

Instance Method Details

#unparseObject

Generate Ruby source as a String



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

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