Class: Howitzer::Meta::Section

Inherits:
Object
  • Object
show all
Includes:
Actions
Defined in:
lib/howitzer/meta/section.rb

Overview

This class represents section entity within howitzer meta information interface

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Actions

#highlight, #xpath

Constructor Details

#initialize(name, context) ⇒ Section

Creates meta section element with meta information and utility actions

Parameters:

  • name (String)

    name of the section

  • context (Howitzer::Web::Page)

    page which has this section



11
12
13
14
# File 'lib/howitzer/meta/section.rb', line 11

def initialize(name, context)
  @name = name
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



5
6
7
# File 'lib/howitzer/meta/section.rb', line 5

def context
  @context
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/howitzer/meta/section.rb', line 5

def name
  @name
end

Instance Method Details

#capybara_elementCapybara::Node::Element?

Finds section on the page and returns as a capybara element

Returns:

  • (Capybara::Node::Element, nil)


24
25
26
27
# File 'lib/howitzer/meta/section.rb', line 24

def capybara_element
  section = context.send("#{name}_sections").first
  section.try(:capybara_context)
end

#capybara_elementsArray

Finds all instances of section on the page and returns them as array of capybara elements

Returns:

  • (Array)


18
19
20
# File 'lib/howitzer/meta/section.rb', line 18

def capybara_elements
  context.send("#{name}_sections").map(&:capybara_context)
end