Class: EhbrsRubyUtils::Booking::Parsers::List

Inherits:
Aranha::Parsers::Html::ItemList
  • Object
show all
Defined in:
lib/ehbrs_ruby_utils/booking/parsers/list.rb

Defined Under Namespace

Modules: NodeParserExtra

Constant Summary collapse

ITEMS_XPATH =
'//*[@data-testid="property-card"]'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.testid_xpath(value, *suffixes) ⇒ Object



11
12
13
# File 'lib/ehbrs_ruby_utils/booking/parsers/list.rb', line 11

def testid_xpath(value, *suffixes)
  ([".//*[@data-testid='#{value}']"] + suffixes).join('/')
end

Instance Method Details

#dataObject



29
30
31
# File 'lib/ehbrs_ruby_utils/booking/parsers/list.rb', line 29

def data
  { accommodations: items_data, declared_count: declared_count }
end

#declared_countInteger

Returns:

  • (Integer)


34
35
36
# File 'lib/ehbrs_ruby_utils/booking/parsers/list.rb', line 34

def declared_count
  node_parser.integer_value(nokogiri, '//h1/text()')
end

#items_xpathObject



38
39
40
# File 'lib/ehbrs_ruby_utils/booking/parsers/list.rb', line 38

def items_xpath
  ITEMS_XPATH
end

#node_parserObject



42
43
44
45
46
# File 'lib/ehbrs_ruby_utils/booking/parsers/list.rb', line 42

def node_parser
  r = super
  r.extend(NodeParserExtra)
  r
end