Class: ViewModel::BaseViewModel

Inherits:
Object
  • Object
show all
Defined in:
lib/view_model/base_view_model.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml_doc) ⇒ BaseViewModel

Returns a new instance of BaseViewModel.



3
4
5
# File 'lib/view_model/base_view_model.rb', line 3

def initialize(xml_doc)
  @xml_doc = xml_doc
end

Instance Method Details

#xpath(queries, node = @xml_doc) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/view_model/base_view_model.rb', line 7

def xpath(queries, node = @xml_doc)
  queries.each do |query|
    if node
      node = node.at query
    else
      return nil
    end
  end
  node ? node.content : nil
end