Class: Howitzer::Meta::Entry
- Inherits:
-
Object
- Object
- Howitzer::Meta::Entry
- Defined in:
- lib/howitzer/meta/entry.rb
Overview
This class provides access to meta information entities
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#element(name) ⇒ Meta::Element
Finds element by name.
-
#elements ⇒ Array
Returns array of elements.
-
#iframe(name) ⇒ Meta::Iframe
Finds iframe by name.
-
#iframes ⇒ Array
Returns array of iframes.
-
#initialize(context) ⇒ Entry
constructor
Creates new meta entry instance for the page which provides access to elements, iframes and sections.
-
#section(name) ⇒ Meta::Section
Finds section by name.
-
#sections ⇒ Array
Returns array of sections.
Constructor Details
#initialize(context) ⇒ Entry
Creates new meta entry instance for the page which provides access to elements, iframes and sections
9 10 11 |
# File 'lib/howitzer/meta/entry.rb', line 9 def initialize(context) @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/howitzer/meta/entry.rb', line 5 def context @context end |
Instance Method Details
#element(name) ⇒ Meta::Element
Finds element by name
25 26 27 |
# File 'lib/howitzer/meta/entry.rb', line 25 def element(name) elements.find { |el| el.name == name.to_s } end |
#elements ⇒ Array
Returns array of elements
15 16 17 18 19 20 |
# File 'lib/howitzer/meta/entry.rb', line 15 def elements @elements ||= context .private_methods .grep(/\A(?!wait_)\w+_element\z/) .map { |el| Meta::Element.new(el.to_s.gsub('_element', ''), context) } end |
#iframe(name) ⇒ Meta::Iframe
Finds iframe by name
57 58 59 |
# File 'lib/howitzer/meta/entry.rb', line 57 def iframe(name) iframes.find { |el| el.name == name.to_s } end |
#iframes ⇒ Array
Returns array of iframes
47 48 49 50 51 52 |
# File 'lib/howitzer/meta/entry.rb', line 47 def iframes @iframes ||= context .public_methods .grep(/\A(?!wait_)\w+_iframe$\z/) .map { |el| Meta::Iframe.new(el.to_s.gsub('_iframe', ''), context) } end |
#section(name) ⇒ Meta::Section
Finds section by name
41 42 43 |
# File 'lib/howitzer/meta/entry.rb', line 41 def section(name) sections.find { |el| el.name == name.to_s } end |